Standards for Date/Time addition?

前端 未结 8 1236
自闭症患者
自闭症患者 2021-02-02 15:40

I\'m looking for standards for Date/Time addition. I haven\'t been able to find any. In particular I\'m hoping to find a spec that defines what should happen when you add a mont

8条回答
  •  野性不改
    2021-02-02 16:04

    There is no widely accepted standard. The reason for the different implementations is that folks can't agree on what the standard should be. Many popular software systems give answers that no one would expect. Documentation is always necessary, therefore, to tell the user what your system will deliver. You choose a methodology, however, based on what you think most folks will expect.

    I think most people on the street would agree that:

    1. You can't define a 'month' by a certain number of days. So...
    2. When it's Jan 31 and someone says "I'll meet you a month from today", they mean the last day of February. Basically, it's add to the month, then find the day number that is closest to today without exceeding it.

    The exception comes in accounting, where sometimes a month means 30 days.

    EDIT: I asked some folks around here, "If it's March 31 and someone says I'll meet you a month from today, what day are you going to meet them?" Most said, April 30, but a few said April 28 because it's four weeks away. The few were interpreting work schedules and thinking "if we met on this weekday, we'll meet again on the same weekday". Basically, if they met on the last Thursday of the month, and they're due to meet in one month, it'll be on the last Thursday of that month.

    So, there ya go. :\

提交回复
热议问题