mmmm think I agree except for preferring to going to last day of m rather than first day of m+1 because otherwise you can end up in the situation where month - 1 leaves you in the same month which does not seem right.
otherwise I think your logic is spot-on, and I was confusing myself by considering the lengths of the months inbetween rather than just considering the final landing month. On Friday, 20 September 2019 16:34:31 UTC+3, Greg Troxel wrote: > > Andrew Milner <[email protected] <javascript:>> writes: > > > what you say is correct if dealing with one month ago - but lets now > > imagine it is say 31 may and we wish to go back 2, 3 or 4 months - where > > should we end up?? > > My take is that if someone asks a fuzzy question and gets an answer that > is in the set of arguably reasonable answers, it's ok. I think that's > far better than throwing an exception. > > For going back N months from y/m/d: > > m -= N > > while m < 1, then {y -= 1; m += 12 } > > if ( d is not valid for m ) > move to the 1st of m+1 > > and call that good enough. > > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/117b0ca0-ec72-4f20-8a22-3e0dd6237a1b%40googlegroups.com.
