Re:Good Design is Imperfect Design, Part 1: Honest Names
by mjevans on Wednesday August 04, 2021 @06:56PM
(#28067519)
No, you should be able to express it the way I mentioned in other examples: Base .plus( N months ) where N is whichever month after the reference you want.
.plus .plus .plus isn't correct because "x months" doesn't have a fixed size. You are NOT saying Base .plus(30 days), NOR are you saying Base .plus(4 weeks) ((which BTW, I'd expect to stay on the same weekday)). You're incrementing by an unstable value.
Re:Good Design is Imperfect Design, Part 1: Honest Names
by saurik on Wednesday August 04, 2021 @09:27PM
(#28068655)
This doesn't work either as it wouldn't work correctly if started in a month with less than 31 days. To represent "the last day of the month" you really need to be subtracting one day from the first day of the next month, full stop: any solution working off of these weird rounding rules is going to be unreliable.
Re:Good Design is Imperfect Design, Part 1: Honest Names
by mcphage on Wednesday August 04, 2021 @08:02PM
(#28068035)
> Shouldn't I be able to express this as a repeated addition of a month?
I don’t think so, no—more likely, it should be Pattern(Month)… like how would you express “second Tuesday” as a series of additions?
Re:Good Design is Imperfect Design, Part 1: Honest Names
by saurik on Wednesday August 04, 2021 @09:26PM
(#28068645)
To express this in a sane way you want to express "the last day of the month". You can't claim it is "just keep adding to the hire date one month times the current month minus the hire month" as if I hire you in February that won't work. You really need to be calculating "take the current time, replace the day with 1, add one month, subtract one day" to get the next pay date.
At any rate, these problems have been solved in finance, with proper date and schedule libraries.