2 ms·
because 1m = [28d,29d,30d,31d] depending on which month you are in. By adding 1d, pre or post, it can alter the definition of 1m.
by 32bitkid 11y ago
because 1m = [28d,29d,30d,31d] depending on which month you are in. By adding 1d, pre or post, it can alter the definition of 1m.
- xixi77 11y agoSure (assuming that's how a "month" is defined in this context -- I haven't actually read the whole article, so I'm not sure); but why do you find the Java syntax less confusing? They look pretty equivalent, except for one is shorter than the other.
- henrikschroder 11y agoBy splitting the addition up into two discrete calls, the ordering is made much more explicit, there's no room for ambiguity. In C#, the largest part of a TimeSpan is a day, you can't have a TimeSpan of "one month and one day", because adding that to a DateTime would add a different amount of absolute time depending on the DateTime. You can have a TimeSpan of "32 days", and adding that to any DateTime yields a consistent result.
- nickpsecurity 11y ago1h4m is 1 hr then 4 min. Order is explicit unless language rules obfuscate it.
- nickpsecurity 11y agoIh ok. Sounds like we can keep first style just make order of operations clear and with rules to catch this. Second syntax woukd appear to require same checks. Again, equivalent intent and problems with more verbosity in 2.