Module: rgjs/time

RGJS6 Time module.

Methods


<static> asAuto(time)

Get human-readable representation of timestamp.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asDays(time)

Get timestamp in days.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asHours(time)

Get timestamp in hours.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asMinutes(time)

Get timestamp in minutes.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asMonths(time)

Get timestamp in months.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asSeconds(time)

Get timestamp in seconds.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asWeeks(time)

Get timestamp in weeks.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> asYears(time)

Get timestamp in years.

Parameters:
Name Type Description
time number

Time in milliseconds.

Returns:
Type
number

<static> autoAgo(timeInPast [, timeCurrent] [, long] [, short])

Calc time between two timestamps and then figure the best way to 'pretty print' that diff.

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

long boolean <optional>

If true, add more info to the result (example: '1 year(s), 2 month(s)' instead of just '1 year(s)').

short boolean <optional>

If true, return a short result ('1y' instead of '1 year(s)').

Returns:

A human readable representation of the difference between timestamps.

Type
number

<static> daysAgo(timeInPast [, timeCurrent])

Calc number of days between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of days between the timestamps

Type
number

<static> daysAgoAsTime(daysAgo)

Get a timestamp for X days ago.

Parameters:
Name Type Description
daysAgo number

The number of days in the past.

Returns:

A timestamp, milliseconds since epoch.

Type
number

<static> hoursAgo(timeInPast [, timeCurrent])

Calc number of hours between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of hours between the timestamps

Type
number

<static> humanReadableTimeAgo(timeInPast [, timeCurrent])

Get a human readable 'ago' time. It returns a date format based on how long ago it was.
Example: 'Today, 15:03' makes more sense than today's full date and time. So does 'Monday, 15:03' when it's been less than a week. 'Mon 3 Oct, 15:03', and '3 Oct 2016'.
Note: requires Steven Levithan's Date.format(), see http://blog.stevenlevithan.com/archives/date-time-format

Parameters:
Name Type Argument Description
timeInPast int
timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:
Type
string

<static> minutesAgo(timeInPast [, timeCurrent])

Calc number of minutes between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of minutes between the timestamps

Type
number

<static> monthsAgo(timeInPast [, timeCurrent])

Calc number of months between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of months between the timestamps

Type
number

<static> weeksAgo(timeInPast [, timeCurrent])

Calc number of weeks between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of weeks between the timestamps

Type
number

<static> yearsAgo(timeInPast [, timeCurrent])

Calc number of years between two timestamps (note: value is 'floored', so 0.8 = 0).

Parameters:
Name Type Argument Description
timeInPast number

A timestamp in the past.

timeCurrent number <optional>

The current time (default) or another timestamp.

Returns:

The number of years between the timestamps

Type
number