Design
Interval and Duration
List of function to manipulate and transform your JSON dates
COMMUNITY FEATURE
Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
v4.0+
:formatI(patternOut, patternIn)
v4.1.0+
Format intervals and duration. List of format name :
human+
human
millisecond(s)
orms
second(s)
ors
minute(s)
orm
hour(s)
orh
year(s)
ory
month(s)
orM
week(s)
orw
day(s)
ord
Params | Description | Type |
---|---|---|
patternOut | output format: human, human+, milliseconds, seconds, ... | String |
patternIn | [optional] input unit: milliseconds, seconds, ... | String |
Examples
// With API options: {
// "lang": "en",
// "timezone": "Europe/Paris"
// }
2000:formatI('second') // 2
2000:formatI('seconds') // 2
2000:formatI('s') // 2
3600000:formatI('minute') // 60
3600000:formatI('hour') // 1
2419200000:formatI('days') // 28
// With API options: {
// "lang": "fr",
// "timezone": "Europe/Paris"
// }
2000:formatI('human') // "quelques secondes"
2000:formatI('human+') // "dans quelques secondes"
-2000:formatI('human+') // "il y a quelques secondes"
// With API options: {
// "lang": "en",
// "timezone": "Europe/Paris"
// }
2000:formatI('human') // "a few seconds"
2000:formatI('human+') // "in a few seconds"
-2000:formatI('human+') // "a few seconds ago"
// With API options: {
// "lang": "en",
// "timezone": "Europe/Paris"
// }
60:formatI('ms', 'minute') // 3600000
4:formatI('ms', 'weeks') // 2419200000
// With API options: {
// "lang": "en",
// "timezone": "Europe/Paris"
// }
'P1M':formatI('ms') // 2628000000
'P1Y2M3DT4H5M6S':formatI('hour') // 10296.085