sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

Calendar arithmetic for DateTimes #517

Closed sharkdp closed 3 months ago

sharkdp commented 3 months ago

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]