-
Notifications
You must be signed in to change notification settings - Fork 593
Description
I'm porting code which makes use of the normalisation features of C's timegm
)
The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to their normal ranges, and will be normalized if needed. For example, October 40 is changed into November 9, a tm_hour of -1 means 1 hour before midnight, tm_mday of 0 means the day preceding the current month, and tm_mon of -2 means 2 months before January of tm_year. (A positive or zero value for tm_isdst causes mktime() to presume initially that summer time (for example, Daylight Saving Time) is or is not in effect for the specified time, respectively. A negative value for tm_isdst causes the mktime() function to attempt to divine whether summer time is in effect for the specified time. The tm_isdst and tm_gmtoff members are forced to zero by timegm(.))
I couldn't see anything in the current Chrono API which looks suitable for this, though it looks like I could manually do it by calling checked_add_months
, checked_add_days
, etc (though as negative values are possible I'd need to test and call the sub
functions too.)
Is there a part of the API that I missed, or does anyone know of another Rust library that can handle this?