Period

Somewhat of an odd feature. Converting a timespan into chunks.

Functions

Util.period

Definition

Name
Util.period
Syntax
String = Util.period( String format [, JSON time ] );

Description

Format time in a readable manner or convert time formats.

Parameters

format
String Format setting for output
Options
y
Total years: 0 - infinity - NOT IMPLEMENTED
n
Months split by years: 0 - 11 - NOT IMPLEMENTED
o
Months split by years, with leading zeros: 00 - 11 - NOT IMPLEMENTED
O
Total months: 0 - infinity - NOT IMPLEMENTED
w
Weeks split by months: 0 - 4 - NOT IMPLEMENTED
W
Total weeks: 0 - infinity - NOT IMPLEMENTED
c
Days split by months: 0 - 30 - NOT IMPLEMENTED
d
Days split by months, with leading zeros: 00 - 30 - NOT IMPLEMENTED
e
Days split by weeks, with leading zeros: 0 - 6 - NOT IMPLEMENTED
D
Total days: 0 - infinity
h
Hours split by days, with leading zeros: 00 - 23
H
Total hours: 0 - infinity
l
Minutes split by hours: 0 - 59
m
Minutes split by hours, with leading zeros: 00 - 59
M
Total minutes: 0 - infinity
r
Seconds split by minutes: 0 - 59
s
Seconds split by minutes, with leading zeros: 00 - 59
S
Total seconds: 0 - infinity
t
Deciseconds, 1 digit: 0 - 9
T
Centiseconds, 2 digits, with leading zeros: 00 - 99
u
Milliseconds, 3 digits, with leading zeros: 000 - 999
U
Total milliseconds: 0 - infinity
time
JSON Optional, JSON object with time argument
Options

One rules out the other, last entry counts.

seconds
time in seconds
milliseconds
time in milliseconds
minutes
time in minutes
hours
time in hours
days
time in days
months
time in months
years
time in years

Return values

String Formatted time string

Examples

u.period("m:s.u", {"seconds":13.31809});

Returns

u.period("D h:m:s.u", {"seconds":2013034.2347});

Returns

u.period("D", {"years":2});

Returns

u.period("H", {"months":4});

Returns

Dependencies

JavaScript
  • typeof
  • Switch ... case
  • Math.floor
  • Math.round
  • String.replace
Manipulator

Nothing

Files

Main file

  • u-period.js

Segment support files

  • none

Segment dependencies

desktop_edge
u-period.js
desktop_ie11
u-period.js
desktop
u-period.js
desktop_ie10
u-period.js
desktop_ie9
u-period.js
desktop_light
u-period.js
tablet
u-period.js
tablet_light
u-period.js
smartphone
u-period.js
mobile
not tested
mobile_light
not tested
tv
u-period.js
seo
not supported