Namespace: Duration

mindsmine.Duration

A collection of useful static methods to deal with duration.

Duration is the amount of elapsed time between two events.

Since:
  • 4.5.0

Members

(static, constant) DAYS_IN_WEEK

Number of days in a week.

Since:
  • 4.6.0

(static, constant) HOURS_IN_DAY

Number of hours in a day.

Since:
  • 4.6.0

(static, constant) HOURS_IN_WEEK

Number of hours in a week.

Since:
  • 4.6.0

(static, constant) MILLISECONDS_IN_DAY

Number of milliseconds in a day.

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_HOUR

Number of milliseconds in an hour.

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_MINUTE

Number of milliseconds in a minute.

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_MONTH

Number of milliseconds in a month (30 days).

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_SECOND

Number of milliseconds in a second.

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_WEEK

Number of milliseconds in a week.

Since:
  • 4.5.0

(static, constant) MILLISECONDS_IN_YEAR

Number of milliseconds in a non leap year.

Since:
  • 4.5.0

(static, constant) MINUTES_IN_DAY

Number of minutes in a day.

Since:
  • 4.6.0

(static, constant) MINUTES_IN_HOUR

Number of minutes in an hour.

Since:
  • 4.6.0

(static, constant) MINUTES_IN_WEEK

Number of minutes in a week.

Since:
  • 4.6.0

(static, constant) MONTHS_IN_YEAR

Number of months in a year.

Since:
  • 4.6.0

(static, constant) SECONDS_IN_DAY

Number of seconds in a day.

Since:
  • 4.5.0

(static, constant) SECONDS_IN_HOUR

Number of seconds in an hour.

Since:
  • 4.5.0

(static, constant) SECONDS_IN_MINUTE

Number of seconds in a minute.

Since:
  • 4.5.0

(static, constant) SECONDS_IN_WEEK

Number of seconds in a week.

Since:
  • 4.5.0

Methods

(static) crudeDiff(startDate, endDate) → {Object}

Converts the length of duration into crude human readable information.

Parameters:
Name Type Description
startDate Date

Start Date

endDate Date

End Date

Since:
  • 4.6.0
Deprecated:
  • Yes
Throws:

for invalid arguments

Type
TypeError
Returns:

An instance of the mindsmine.DurationHolder object.

Type
Object

(static) humanreadable(duration, unitopt) → {Object}

Approximately converts the length of duration into a human readable information.

Note: This is not an accurate representation. This function assumes a year of 365 days and a month of 30 days.

Parameters:
Name Type Attributes Default Description
duration Number

to be converted into a human readable information

unit String <optional>
"ms"

the unit level of the duration to be converted

Since:
  • 4.6.0
Throws:
  • for invalid arguments

    Type
    TypeError
  • for invalid unit level

    Type
    RangeError
Returns:

An instance of the mindsmine.DurationHolder object.

Type
Object

(static) preciseDiff(startDate, endDate) → {Object}

Converts the length of duration into inituitive human readable information.

Parameters:
Name Type Description
startDate Date

Start Date

endDate Date

End Date

Since:
  • 4.5.0
Throws:

for invalid arguments

Type
TypeError
Returns:

An instance of the mindsmine.DurationHolder object.

Type
Object