-
Notifications
You must be signed in to change notification settings - Fork 294
Open
Labels
Description
Now that Temporal ships in most browsers and will likely ship in a future version of Node.js, we should see if it could replace ms.
A few examples:
Temporal.Duration.from({ seconds: 5 }).total({ unit: 'milliseconds' }); // 5000
Temporal.Duration.from({ minutes: 3 }).total({ unit: 'milliseconds' }); // 180000
Temporal.Duration.from({ hours: 2 }).total({ unit: 'milliseconds' }); // 7200000
Temporal.Duration.from({ days: 1 }).total({ unit: 'milliseconds' }); // 86400000There is even short hand string syntax (ISO 8601) such as:
Temporal.Duration.from('PT5S').total({ unit: 'milliseconds' }); // 5000
Temporal.Duration.from('PT3M').total({ unit: 'milliseconds' }); // 180000
Temporal.Duration.from('PT2H').total({ unit: 'milliseconds' }); // 7200000
Temporal.Duration.from('P1D').total({ unit: 'milliseconds' }); // 86400000There are still other features to consider and it only makes sense if we can make ms smaller than it already is.
In an ideal world, you wouldn't need to install ms at all 😄
Reactions are currently unavailable