Skip to content

Duration / time units in Amount #139

Description

@sffc

Related: #118, tc39/proposal-intl-sequence-units#8

units.xml defines a bunch of duration units and some conversions between them:

        <!-- time -->
        <convertUnit source='second' baseUnit='second' systems="si metric prefixable ussystem uksystem astronomical"/>
        <convertUnit source='minute' baseUnit='second' factor='60' systems="si_acceptable metric_adjacent prefixable ussystem uksystem astronomical"/>
        <convertUnit source='hour' baseUnit='second' factor='3600' systems="si_acceptable metric_adjacent prefixable ussystem uksystem astronomical"/>
        <convertUnit source='day' baseUnit='second' factor='86400' systems="si_acceptable metric_adjacent prefixable ussystem uksystem astronomical"/>
        <convertUnit source='day-person' baseUnit='second' factor='86400' systems="person_age"/>
        <convertUnit source='week' baseUnit='second' factor='86400*7' systems="metric_adjacent ussystem uksystem astronomical"/>
        <convertUnit source='week-person' baseUnit='second' factor='86400*7' systems="person_age"/>
        <convertUnit source='fortnight' baseUnit='second' factor='86400*14' systems="ussystem uksystem"/>
        
        <!-- year-duration -->
        <convertUnit source='month' baseUnit='year' factor='1/12' systems="metric_adjacent ussystem uksystem astronomical"/>
        <convertUnit source='month-person' baseUnit='year' factor='1/12' systems="person_age"/>
        <convertUnit source='quarter' baseUnit='year' factor='1/4' systems="metric_adjacent"/>
        <convertUnit source='year' baseUnit='year' systems="metric_adjacent prefixable ussystem uksystem astronomical"/>
        <convertUnit source='year-person' baseUnit='year' systems="person_age"/>
        <convertUnit source='decade' baseUnit='year' factor='10' systems="metric_adjacent ussystem uksystem astronomical"/>
        <convertUnit source='century' baseUnit='year' factor='100' systems="metric_adjacent ussystem uksystem astronomical"/>
        
        <!-- night-duration -->
        <convertUnit source='night' baseUnit='night' systems="metric_adjacent uksystem ussystem"/>     

However, we have Temporal.Duration already in JavaScript for handling duration units and conversions, which was designed to better handle the edge cases involved with duration units; see this presentation for details.

CLDR is a baseline, but TC39 should take ECMAScript-specific considerations into account, not just blindly take everything that is in units.xml.

Some questions:

  • Should we support time/duration units at all? If so, which ones?
  • Should we support conversions between time/duration units? If so, which ones?
  • Should we support time/duration units in sequence units? If so, which ones?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions