• tetris11@lemmy.ml
    ·
    10 months ago

    The past is the past. Everything that happened before time t_now should be set to Inf. I thank you for your ears.

  • sebsch@discuss.tchncs.de
    ·
    10 months ago

    I mean, as long you only need the delta in milliseconds it's easy. Just count the milliseconds from 1970 to the event. The problem starts when you want to have a human readable representation.

    It's calenders they suck, not time.

    • mormegil@programming.dev
      ·
      10 months ago

      Well... unless you measure the number of [milli]seconds using something like time_t, which lies because of leap seconds. I.e. even such a seemingly simple interface, in fact, includes a calendar.

  • Amaltheamannen@lemmy.ml
    ·
    10 months ago

    Sounds like a distributed systems problem. While the time between events could be impossible (can't guarantee clocks are synchronized) you can use a logical clock to have causaul ordering.

  • tias@discuss.tchncs.de
    ·
    edit-2
    10 months ago

    I feel like this is a solved and simple problem as long as there are no relativistic effects. Just make sure t1 and t2 are represented as seconds since a known reference time, e.g. Unix epoch, and make sure that measure is accurate. You don't need to bring the Gregorian calendar into it, use TAI represented as an integer.

      • tias@discuss.tchncs.de
        ·
        edit-2
        10 months ago

        To do that you first need to choose a calendar and a time zone, then convert to that representation. It can be done, but you need a good implementation that understands the entire history of what has transpired w.r.t. to date conventions in that location and culture. For timestamps in the future it is impossible to do correctly, since you can't know how date conventions will change in the future.

        However, I should add that as far as mathematical operations go, calculating the number of months between t1 and t2 is an entirely different thing than the duration of time that passed between those timestamps. Even if it is expressed similarly in the English language, semantically it's something else. It's like asking "how many kilometers did your car go" vs "how many houses did the car pass on the way".