active-icalendar-events 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active-icalendar-events.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee9cc0c47ee4498afaf37e853db464fca142261bbf29aaa17439f66508c2610c
|
4
|
+
data.tar.gz: a3e5972072dbb410c1949cc2d53a7e7db741e55d9619ed628cc97c2ed2a3d1bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9dbc20940280b719b5d4770e2e2de94544d5671a4b9aa1b6eceb41a126077d44e8d101eabd599f9885de7112d658000b199d8e305900d730b1f173565e94f8
|
7
|
+
data.tar.gz: f269876565330984d37d22c592dbef52102d774c387399698af734136347bb90387bea64a6dd25e6b0f64745a946e48d1efb593576966d31e7ec281d3e17cf34
|
@@ -251,6 +251,11 @@ module ActiveIcalendarEvents
|
|
251
251
|
false
|
252
252
|
end
|
253
253
|
|
254
|
+
# Get the beginning of the month, maintaining the timestamp
|
255
|
+
def beginning_of_month(datetime)
|
256
|
+
datetime - (datetime.day - 1).days
|
257
|
+
end
|
258
|
+
|
254
259
|
def get_nth_day_in_month(datetime, day)
|
255
260
|
matches = day.match /^([0-9]+)([A-Z]+)$/
|
256
261
|
if matches.nil?
|
@@ -278,7 +283,7 @@ module ActiveIcalendarEvents
|
|
278
283
|
raise RuntimeError, "Unexpected day code used"
|
279
284
|
end
|
280
285
|
|
281
|
-
target_day = datetime
|
286
|
+
target_day = beginning_of_month(datetime)
|
282
287
|
|
283
288
|
if target_day.strftime("%^a").chop != day_code
|
284
289
|
target_day = target_day.next_occurring(day_label)
|
@@ -326,7 +331,7 @@ module ActiveIcalendarEvents
|
|
326
331
|
event_end_considered = event_end_considered + interval.month
|
327
332
|
else
|
328
333
|
event_start_considered =
|
329
|
-
get_nth_day_in_month(event_start_considered
|
334
|
+
get_nth_day_in_month(beginning_of_month(event_start_considered) + interval.month,
|
330
335
|
by_day.first)
|
331
336
|
event_end_considered = event_start_considered + (event_end.to_time - event_start.to_time).seconds
|
332
337
|
end
|