Skip to content

datetime.getPartsFromSeconds

Kerri Shotts edited this page Apr 5, 2014 · 1 revision

(part of datetime)

Parameters:

  • seconds
  • precision - Any of the PRECISION constants

Returns: { fractions: #, seconds: #, minutes: #, hours: #, days: #, weeks: #, years: # }

Given a specific number of seconds, one often needs to convert that into something more readable -- like "3 hours, 23 minutes, 43 seconds".

The precision calculates how far the method takes this conversion:

  • PRECISION_SECONDS: only fractional seconds and seconds will be calculated.
  • PRECISION_MINUTES: Seconds will be converted into minutes, seconds, and fractional seconds.
  • PRECISION_HOURS: Seconds will be converted into hours, minutes, seconds, and fractional seconds.
  • PRECISION_DAYS: Seconds will be converted into days, hours, minutes, seconds, and fractional seconds.
  • PRECISION_WEEKS: Seconds will be converted into weeks, days, hours, minutes, seconds, and fractional seconds.
  • PRECISION_YEARS: Seconds will be converted into years, weeks, days, hours, minutes, seconds, and fractional seconds.

Usage

var timeComponents = _y.datetime.getPartsFromSeconds ( 125.13, _y.datetime.PRECISION_MINUTES );
// { fractions: .13, seconds: 5, minutes: 2 }
Clone this wiki locally