Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "index"

This is the main module of timecount. Employ one of the following snippets to use it in your project:

  • EcmaScript 6 or equivalent:
    import { Time, TimeWriter } from "timecount";
    
  • Older EcmaScripts:
    var timecount = require("timecount");
    

đź’ˇ Importing from "/index" is unnecessary but nobody is going to stop you from doing it: var timecount = require("timecount/index");


This module contains the time encapsulation used throughout the project and the implementation for outputting synthetic time value strings (time writers). It relies on big.js for the precision of its floating-point operations, specially considering how JS handles these things.

It also exports both other modules, localization and utils, as properties of itself, so they can be easily accessed when importing timecount as a whole:

var timecount = require("timecount");

// Accessing sub-modules directly:
timecount.Locale.set("es-mx");
var timer = new timecount.utils.Timer();

Index

Type aliases

NumericNotation

NumericNotation: "decimal" | "roman" | "roman-fractions" | "scientific"

This type contains all values accepted when configuring numeric notations.

  • "decimal": standard Hindu–Arabic numeral system using base ten;
  • "roman": Ancient Rome numeral system, ignoring fractions;
  • "roman-fractions": Ancient Rome numeral system, using common fractions;
  • "scientific": Exponent notation; writes very small and very large numbers using powers of 10.

NumericWriter

NumericWriter: (value: number, bigValue?: Decimal) => string

This type defines functions used by time writers in order to express a numeric value in the form of text.

The first parameter is a native number and the second, optional, is a big decimal.

Type declaration

    • (value: number, bigValue?: Decimal): string
    • Parameters

      • value: number
      • Optional bigValue: Decimal

      Returns string

TimeUnitParameter

TimeUnitParameter: keyof TimeUnitDatabase | TimeUnit

A union type, used by parameters that accept either the name of a time unit or a time unit object.

deprecated

Since v1.1.0 - In favor of TimeUnitSource (will be removed in v2).

TimeUnitSource

TimeUnitSource: keyof TimeUnitDatabase | TimeUnit

A union type, used by parameters that accept either the name of a time unit or a time unit object.

The accepted names are the properties defined by TimeUnitDatabase, but case-insensitive and plural variations are also valid (even though TypeScript would not allow it).

TimeValueSource

TimeValueSource: string | number | Decimal

This type is a union of all accepted types that can be used to represent a time value: a string that parses to a number (e.g. "1000" or "1e-10"), a big decimal or a number.

Variables

Const timeUnits

timeUnits: TimeUnitDatabase<TimeUnit> = TimeUnits

Alias to TimeUnits.

deprecated

Since v1.1.0 - Incorrect naming, all exported constants are now capitalized (will be removed in v2).

Functions

writeRoman

  • writeRoman(value: number | Decimal, fractions?: boolean): string
  • Writes a numeric value using numerals from the Ancient Rome.

    Parameters

    • value: number | Decimal

      A number or big decimal to be converted to roman.

    • Default value fractions: boolean = false

      Whether to include common fractions or not.

    Returns string

    A string with the roman representation of the given number.

writeRomanFractions

  • writeRomanFractions(value: number | Decimal): string
  • Writes the fraction part of a numeric value using common fractions from the Ancient Rome.

    Parameters

    • value: number | Decimal

      A number that will have its decimal part extracted and written in roman.

    Returns string

    A string with the roman representation of the given fraction.

Object literals

Const TimeSegments

TimeSegments: object

Objects pertaining to this constant can be used as a parameter value for the countdown method of time writers.

These constants contains groups of time units that are related.

baseTen

baseTen: string[] = ["yottasecond", "zettasecond", "exasecond", "petasecond", "terasecond", "gigasecond", "megasecond","kilosecond", "second", "millisecond", "microsecond", "nanosecond", "picosecond", "femtosecond", "attosecond","zeptosecond", "yoctosecond"]

All base ten SI time units.

binary

binary: string[] = ["yobisecond", "zebisecond", "exbisecond", "pebisecond", "tebisecond", "gibisecond", "mebisecond","kibisecond", "second"]

All base two binary time units.

common

common: string[] = ["year", "month", "day", "hour", "minute", "second"]

Common time unit segmentation: year, month, day, hour, minute and second.

extremes

extremes: string[] = ["planckTime", "nanosecond", "yobisecond"]

Extremes and the middle-point of timecount units: Planck time, nanosecond and yobisecond.

sidereal

sidereal: string[] = ["siderealYear", "siderealMonth", "siderealDay", "siderealHour", "siderealMinute", "siderealSecond"]

Contains all units of a sidereal time.

Const TimeUnits

TimeUnits: object

A database of time units, used to qualify and describe lengths of time.

Each property of this object enumerates the linguistic and mathematical features of the time unit it represents.


See TimeUnitDatabase for more information about time units.

anomalisticMonth

anomalisticMonth: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.38071312e+15")

anomalisticYear

anomalisticYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("3.15584325504e+16")

attosecond

attosecond: object

factor

factor: Decimal = new Decimal("1e-9")

symbol

symbol: string = "as"

biennium

biennium: object

customPlural

customPlural: string = "biennia"

factor

factor: Decimal = new Decimal("6.3113904e+16")

century

century: object

customPlural

customPlural: string = "centuries"

factor

factor: Decimal = new Decimal("3.1536e+18")

cosmicYear

cosmicYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("7.4898e+24")

day

day: object

factor

factor: Decimal = new Decimal("8.64e+13")

symbol

symbol: string = "d"

decade

decade: object

factor

factor: Decimal = new Decimal("3.1556952e+17")

draconicMonth

draconicMonth: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.351135808e+15")

draconicYear

draconicYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.994797455629e+16")

eclipticYear

eclipticYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.994797455629e+16")

exasecond

exasecond: object

factor

factor: Decimal = new Decimal("1e+27")

symbol

symbol: string = "Es"

exbisecond

exbisecond: object

factor

factor: Decimal = new Decimal("1.152921504606846976e+27")

symbol

symbol: string = "Eis"

femtosecond

femtosecond: object

factor

factor: Decimal = new Decimal("1e-6")

symbol

symbol: string = "fs"

fortnight

fortnight: object

factor

factor: Decimal = new Decimal("1.2096e+15")

galacticYear

galacticYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("7.4898e+24")

gibisecond

gibisecond: object

factor

factor: Decimal = new Decimal("1.073741824e+18")

symbol

symbol: string = "Gis"

gigasecond

gigasecond: object

factor

factor: Decimal = new Decimal("1e+18")

symbol

symbol: string = "Gs"

gregorianYear

gregorianYear: object

factor

factor: Decimal = new Decimal("3.1556952e+16")

readableName

readableName: string = "Gregorian year"

hour

hour: object

factor

factor: Decimal = new Decimal("3.6e+12")

symbol

symbol: string = "h"

jiffy

jiffy: object

customPlural

customPlural: string = "jiffies"

factor

factor: Decimal = new Decimal("3e-15")

julianYear

julianYear: object

factor

factor: Decimal = new Decimal("3.15576e+16")

readableName

readableName: string = "Julian year"

kibisecond

kibisecond: object

factor

factor: Decimal = new Decimal("1.024e+12")

symbol

symbol: string = "Kis"

kilosecond

kilosecond: object

factor

factor: Decimal = new Decimal("1e+12")

symbol

symbol: string = "Ks"

kiloyear

kiloyear: object

factor

factor: Decimal = new Decimal("3.1536e+19")

symbol

symbol: string = "ky"

leapYear

leapYear: object

factor

factor: Decimal = new Decimal("3.16224e+16")

lustrum

lustrum: object

customPlural

customPlural: string = "lustra"

factor

factor: Decimal = new Decimal("1.5778476e+17")

mebisecond

mebisecond: object

factor

factor: Decimal = new Decimal("1.048576e+15")

symbol

symbol: string = "Mis"

megasecond

megasecond: object

factor

factor: Decimal = new Decimal("1e+15")

symbol

symbol: string = "Ms"

microsecond

microsecond: object

factor

factor: Decimal = new Decimal("1e+3")

symbol

symbol: string = "µs"

millenium

millenium: object

customPlural

customPlural: string = "millennia"

factor

factor: Decimal = new Decimal("3.1556952e+19")

millisecond

millisecond: object

factor

factor: Decimal = new Decimal("1e+6")

symbol

symbol: string = "ms"

minute

minute: object

factor

factor: Decimal = new Decimal("6e+10")

symbol

symbol: string = "min"

month

month: object

factor

factor: Decimal = new Decimal("2.628e+15")

symbol

symbol: string = "m"

nanosecond

nanosecond: object

factor

factor: Decimal = new Decimal("1")

symbol

symbol: string = "ns"

nodicalMonth

nodicalMonth: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.351135808e+15")

nonLeapYear

nonLeapYear: object

factor

factor: Decimal = new Decimal("3.1536e+16")

readableName

readableName: string = "non-leap year"

novennium

novennium: object

customPlural

customPlural: string = "novennia"

factor

factor: Decimal = new Decimal("2.84012568e+17")

octennium

octennium: object

customPlural

customPlural: string = "octennia"

factor

factor: Decimal = new Decimal("2.52455616e+17")

pebisecond

pebisecond: object

factor

factor: Decimal = new Decimal("1.125899906842624e+24")

symbol

symbol: string = "Pis"

petasecond

petasecond: object

factor

factor: Decimal = new Decimal("1e+24")

symbol

symbol: string = "Ps"

picosecond

picosecond: object

factor

factor: Decimal = new Decimal("1e-3")

symbol

symbol: string = "ps"

planckTime

planckTime: object

factor

factor: Decimal = new Decimal("5.39056e-35")

readableName

readableName: string = "Planck time"

symbol

symbol: string = "tâ‚š"

quadrennium

quadrennium: object

customPlural

customPlural: string = "quadrennia"

factor

factor: Decimal = new Decimal("1.26227808e+17")

quindecennium

quindecennium: object

customPlural

customPlural: string = "quindecennia"

factor

factor: Decimal = new Decimal("4.7335428e+17")

quinquennium

quinquennium: object

customPlural

customPlural: string = "quinquennia"

factor

factor: Decimal = new Decimal("1.5778476e+17")

second

second: object

factor

factor: Decimal = new Decimal("1e+9")

symbol

symbol: string = "s"

septennium

septennium: object

customPlural

customPlural: string = "septennia"

factor

factor: Decimal = new Decimal("2.20752e+17")

shake

shake: object

factor

factor: Decimal = new Decimal("10")

siderealDay

siderealDay: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("8.616409e+13")

siderealHour

siderealHour: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("3.590170416667e+12")

siderealMinute

siderealMinute: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("5.983617361111e+10")

siderealMonth

siderealMonth: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.360591424e+15")

siderealSecond

siderealSecond: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("9.972695601852e+8")

siderealYear

siderealYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("3.155814954e+16")

solarDay

solarDay: object

factor

factor: Decimal = new Decimal("8.64e+13")

solarYear

solarYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("3.155693e+16")

svedberg

svedberg: object

factor

factor: Decimal = new Decimal("1e-4")

symbol

symbol: string = "Sv"

synodicMonth

synodicMonth: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("2.55144384e+15")

tebisecond

tebisecond: object

factor

factor: Decimal = new Decimal("1.099511627776e+21")

symbol

symbol: string = "Tis"

terasecond

terasecond: object

factor

factor: Decimal = new Decimal("1e+21")

symbol

symbol: string = "Ts"

timeUnit

timeUnit: object

factor

factor: Decimal = new Decimal("1.024e+6")

symbol

symbol: string = "TU"

tropicalYear

tropicalYear: object

approximated

approximated: true = true

factor

factor: Decimal = new Decimal("3.155693e+16")

week

week: object

factor

factor: Decimal = new Decimal("6.048e+14")

symbol

symbol: string = "w"

year

year: object

factor

factor: Decimal = new Decimal("3.1556952e+16")

symbol

symbol: string = "y"

yobisecond

yobisecond: object

factor

factor: Decimal = new Decimal("1.208925819614629174706176e+33")

symbol

symbol: string = "Yis"

yoctosecond

yoctosecond: object

factor

factor: Decimal = new Decimal("1e-15")

symbol

symbol: string = "ys"

yottasecond

yottasecond: object

factor

factor: Decimal = new Decimal("1e+33")

symbol

symbol: string = "Ys"

zebisecond

zebisecond: object

factor

factor: Decimal = new Decimal("1.180591620717411303424e+30")

symbol

symbol: string = "Zis"

zeptosecond

zeptosecond: object

factor

factor: Decimal = new Decimal("1e-12")

symbol

symbol: string = "zs"

zettasecond

zettasecond: object

factor

factor: Decimal = new Decimal("1e+30")

symbol

symbol: string = "Zs"

Generated using TypeDoc