11
kishan
3y

The feeling when java's plusMonths and monthsBetween are imcompatible 🤦

Comments
  • 0
    Doesn’t between just return the number of whole months between the months of the two dates?
  • 4
    Read the documentation for 'between'. There's even a similar example and explanation, why it works like this.

    https://docs.oracle.com/javase/8/...
  • 9
    @gomsim What is a whole month? 31 days? 28 days?

    If you subMonth() on March 31 in PHP's Carbon library for example, you get 31 February... Which is then converted to March 2 or 3, depending on leap year.

    I propose we start using metric time and Unix Timestamps. Not just for computing, but also in real life.

    I'm going to lunch, see you in 2 kiloseconds.
  • 2
    Why do java developers code in "js hell"?
  • 0
    @bittersweet I don’t know. It was just a thought. But I assume it works by comparing the month attribute. So between(30/1, 30/3) == between(30/1, 1/3).
  • 0
    @bittersweet I skimmed the dokumentation now, provided by iiii, and it turns out i was wrong.
  • 3
    @bittersweet We could just make 13 months, each 28 days long, and have an extra day per year (and another in leap years) which wouldn't be counted in any timespan that happens to start before and end after them. Still broken but not as badly and people get to keep their time units.
  • 3
    @homo-lorens That still doesn't solve time on an interplanetary scale though.

    An 1 Megasecond scrum sprint (~11 earth days) is just 1Ms on Earth, the Moon, Mars, etc.
  • 1
    @bittersweet Yes, but I was more aiming for something that will satisfy the majority of humanity over the course of the next 100 years, not a solution for the unforeseeable future.
  • 2
    @homo-lorens Pfff screw humans and their stupid "humanity"!
  • 2
    @bittersweet Actually I would support a decimal metric time system because I already rely on automatic alerts for 90% of my deadlines, but the vast majority of people try to memorize them in terms of how many times the sun will go down / it will get really cold / they don't have to work two days, and systems that don't align with the terran day-night cycle or year break this workflow.
  • 0
    @bittersweet whole month is a span that starts at day 1 of a month and spans to the end of the month (beit 28, 30 or 31 days)
  • 0
    @bittersweet mega second sounds cool.
  • 0
    @iiii The question is, do we accept the non-SI prefix myriasecond for 2.7 hours?
  • 0
  • 0
Add Comment