3 ms·
I don't know how it works with other frameworks, but with ActiveSupport in Rails, when I want to say "30 days from now", it's "Time.now + 30.days", and Ruby doe
by lsb 17y ago
I don't know how it works with other frameworks, but with ActiveSupport in Rails, when I want to say "30 days from now", it's "Time.now + 30.days", and Ruby does the math from days->seconds.
(IIRC, 1.month = 30.days in Rails.)
- gchpaco 17y agoSee, that's wrong in many circumstances. If I want January 12th, 2019 + 1 month, I expect to get Feb 12th, 2019, not Feb 11th. Also days does not convert well into seconds in UTC, because of leap seconds. Historical dates are even more of a mess--consider September 1752 in Britain and the US, or February 1918 in Russia. (Julian -> Gregorian calendar conversions that caused several days to wink out of existence--there is no September 13th, 1752 in Britain, although there is in France.) There is a February 30, 1712 in Sweden. Calendrical calculations are imposing an artificial setup on a changing system, and have lots of weird anomalies as a result of this.