mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 08:02:28 +00:00
fix: end of week boundary (#508)
This commit is contained in:
@@ -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)?
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
Reference in New Issue
Block a user