Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Does the current proposal make sense outside of the gregorian calendar? #6

@rxaviers

Description

@rxaviers

Update: this can be solved by using a calendar option as Zibi suggests below.


Problem

The current proposal takes a number of ms as argument and calculates the correspondent second, minute, ..., year for formatting, being a positive in the future and a negative in past, which seems very sane.

It happens that some calendards have different months and years lengths [1]. Thankfully, the equation (used here for deducing time units) should always work for seconds, minutes, hours, and days, but it might fail for deducing months and years. For example, in the Chinese Calendar there are 12 or 13 months; in the Islamic Calendar, there are 354 or 355 days year.

In a general sense, e.g., suppose a developer is writing a game where he needs to display the relative time of Martian months, the current calculation doesn't make sense. Note that in this example case, it doesn't make sense even for day.

General thoughts

Above we have a good and a bad news. The bad news is that the problem lies in the calendar calculation and that's usually a tough problem. The good news is that it doesn't have anything to do with internationalization/localization (i18n).

The i18n problem is very simple, it's to display the localized message, e.g., 10 seconds ago where numeric value is -10 and unit is second. Additionally to this problem is whether or not the formatted text is integer or decimal, because it could change the plural form.

The calendar calculation problem is whether or not a bunch of ms corresponds to a bunch of months.

The current relative time proposal tries to solve both problems. It would be easier if it sticks with the i18n problem only.

Any thoughts?

1:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions