fix: end of week boundary (#508)

This commit is contained in:
stefan-gorules
2026-08-19 11:15:21 +02:00
committed by GitHub
parent 13722740a1
commit 32f7fb875c
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -312,10 +312,10 @@ mod helper {
DurationUnit::Hour => date_time.with_minute(59)?.with_second(59)?,
DurationUnit::Day => date_time.with_hour(23)?.with_minute(59)?.with_second(59)?,
DurationUnit::Week => {
let weekday = date_time.weekday().num_days_from_sunday();
let days_until_sunday = 6 - date_time.weekday().num_days_from_monday();
date_time
.checked_add_days(Days::new(weekday.to_u64()?))?
.checked_add_days(Days::new(days_until_sunday.to_u64()?))?
.with_hour(23)?
.with_minute(59)?
.with_second(59)?
+4
View File
@@ -101,6 +101,10 @@ d('2023-10-15').startOf('year');;'2023-01-01T00:00:00Z'
d('2023-10-15').endOf('year');;'2023-12-31T23:59:59Z'
d('2023-10-15').startOf('week');;'2023-10-09T00:00:00Z'
d('2023-10-15').endOf('week');;'2023-10-15T23:59:59Z'
d('2024-01-15').startOf('week');;'2024-01-15T00:00:00Z'
d('2024-01-15').endOf('week');;'2024-01-21T23:59:59Z'
d('2024-01-16').endOf('week');;'2024-01-21T23:59:59Z'
d('2024-01-21').endOf('week');;'2024-01-21T23:59:59Z'
d('2023-10-15').startOf('quarter');;'2023-10-01T00:00:00Z'
d('2023-10-15').endOf('quarter');;'2023-12-31T23:59:59Z'
d('2023-03-15').startOf('quarter');;'2023-01-01T00:00:00Z'
1 expression (string);input (json 5);output (json 5)
101 d('2023-06-15').endOf('quarter');;'2023-06-30T23:59:59Z' d('2023-10-15').endOf('quarter');;'2023-12-31T23:59:59Z'
102 d('2023-09-15').startOf('quarter');;'2023-07-01T00:00:00Z' d('2023-03-15').startOf('quarter');;'2023-01-01T00:00:00Z'
103 d('2023-09-15').endOf('quarter');;'2023-09-30T23:59:59Z' d('2023-03-15').endOf('quarter');;'2023-03-31T23:59:59Z'
104 d('2023-06-15').startOf('quarter');;'2023-04-01T00:00:00Z'
105 d('2023-06-15').endOf('quarter');;'2023-06-30T23:59:59Z'
106 d('2023-09-15').startOf('quarter');;'2023-07-01T00:00:00Z'
107 d('2023-09-15').endOf('quarter');;'2023-09-30T23:59:59Z'
108 # Timezone operations
109 d('2023-10-15T00:00:00Z').tz('America/New_York');;'2023-10-14T20:00:00-04:00'
110 d('2023-10-15T00:00:00Z').tz('Europe/London');;'2023-10-15T01:00:00+01:00'