Hacker News new | past | comments | ask | show | jobs | submit login

Providing comparison functions that work with existing APIs is solid design, should be required reading for any new types added really. Kudos to the designers!

    const durations = [
      Temporal.Duration.from({ hours: 1 }),
      Temporal.Duration.from({ hours: 2 }),
      Temporal.Duration.from({ hours: 1, minutes: 30 }),
      Temporal.Duration.from({ hours: 1, minutes: 45 }),
    ];

    durations.sort(Temporal.Duration.compare);
    console.log(durations.map((d) => d.toString()));
    // [ 'PT1H', 'PT1H30M', 'PT1H45M', 'PT2H' ]



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: