Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL Resource Scheduler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jeff Sturek
UNL Resource Scheduler
Commits
eb174670
Commit
eb174670
authored
8 years ago
by
Tyler Lemburg
Browse files
Options
Downloads
Patches
Plain Diff
DST Fixes
parent
ef21b88a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routes/resources.rb
+22
-7
22 additions, 7 deletions
routes/resources.rb
with
22 additions
and
7 deletions
routes/resources.rb
+
22
−
7
View file @
eb174670
...
...
@@ -227,14 +227,16 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
if
params
[
:recurring_type
]
==
'weekly'
||
params
[
:recurring_type
]
==
'biweeekly'
inc
=
7
.
days
inc
=
14
.
days
if
params
[
:recurring_type
]
==
'biweeekly'
new_start
=
start_time
new_start
=
start_time
.
dup
while
(
new_start
=
new_start
+
inc
)
<=
recurs_until_date
+
1
.
day
starts
<<
new_start
# reset in case we moved past DST change
new_start
=
(
new_start
+
1
.
hour
).
midnight
.
in_time_zone
starts
<<
new_start
+
start_time
.
minutes_after_midnight
.
minutes
end
elsif
%w(
1st 2nd 3rd 4
th)
.
include?
(
params
[
:recurring_type
])
elsif
%w(
first second third four
th)
.
include?
(
params
[
:recurring_type
])
day_of_week
=
start_time
.
wday
new_start
=
start_time
new_start
=
start_time
.
dup
while
(
new_start
<=
recurs_until_date
+
1
.
day
)
# calculate when this is next month
year
=
new_start
.
year
...
...
@@ -246,7 +248,16 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
end
# now add weeks
start_day
+=
(
params
[
:recurring_type
][
0
].
to_i
-
1
).
weeks
weeks
=
{
"first"
=>
1
,
"second"
=>
2
,
"third"
=>
3
,
"fourth"
=>
4
}
start_day
+=
(
weeks
[
params
[
:recurring_type
]]
-
1
).
weeks
# reset this to midnight in case of DST change
start_day
=
(
start_day
+
1
.
hour
).
midnight
.
in_time_zone
# and set the start time
start_day
+=
start_time
.
hour
.
hours
+
start_time
.
min
.
minutes
...
...
@@ -257,13 +268,14 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
end
elsif
params
[
:recurring_type
]
==
'last'
day_of_week
=
start_time
.
wday
new_start
=
start_time
new_start
=
start_time
.
dup
while
(
new_start
<=
recurs_until_date
+
1
.
day
)
# calculate when this is next month
year
=
new_start
.
year
month
=
new_start
.
month
+
1
month
=
1
and
year
+=
1
if
month
==
13
start_day
=
Time
.
new
(
year
,
month
,
1
).
midnight
.
in_time_zone
while
(
start_day
.
wday
!=
day_of_week
)
start_day
=
start_day
+
1
.
day
end
...
...
@@ -272,6 +284,9 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
while
(
start_day
+
1
.
week
).
month
==
month
start_day
+=
1
.
week
end
# reset this to midnight in case of DST change
start_day
=
(
start_day
+
1
.
hour
).
midnight
.
in_time_zone
# and set the start time
start_day
+=
start_time
.
hour
.
hours
+
start_time
.
min
.
minutes
...
...
@@ -281,7 +296,7 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
new_start
=
start_day
end
elsif
params
[
:recurring_type
]
==
'day'
new_start
=
start_time
new_start
=
start_time
.
dup
while
(
new_start
<=
recurs_until_date
+
1
.
day
)
# calculate when this is next month
year
=
new_start
.
year
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment