Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar arithmetic for DateTimes #517

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Calendar arithmetic for DateTimes #517

merged 1 commit into from
Aug 1, 2024

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Aug 1, 2024

Adds calendar_add and calendar_sub which can be used to do DST and leap-year aware calendar arithmetic on DateTimes:

>>> calendar_add(now(), 40 days)

    = 2024-09-10 21:07:41 CEST (UTC +02), Europe/Berlin    [DateTime]

>>> calendar_sub(now(), 6 months)

    = 2024-02-01 21:07:53 CET (UTC +01), Europe/Berlin    [DateTime]

>>> date("2000-01-01") -> weekday

    = "Saturday"    [String]

@sharkdp sharkdp force-pushed the calendar-arithmetic branch from 470d910 to f8e7bfe Compare August 1, 2024 19:11
@sharkdp sharkdp merged commit 46bbe68 into master Aug 1, 2024
15 checks passed
@sharkdp sharkdp deleted the calendar-arithmetic branch August 1, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant