new FuzzyTime()
Constructs a new FuzzyTime instance.
- License:
- MIT
- Source:
Members
-
<static, readonly> Unit :number
-
Enumeration of time units supported by FuzzyTimeJS.
Type:
- number
- Source:
Properties:
Name Type Default Description YEARnumber 6 MONTHnumber 5 WEEKnumber 4 DAYnumber 3 HOURnumber 2 MINUTEnumber 1 SECONDnumber 0
Methods
-
after(format, delta)
-
Configures this FuzzyTime instance to return the given string format (with values plugged in) any time that FuzzyTime#build is called and after the given time delta has passed
Parameters:
Name Type Description formatstring The string format
deltastring | list The time delta at which to display. This can be either an ISO 8601 Duration (string) or a list of maps like:
[ {time: 1, unit: FuzzyTime.Unit.MINUTE}, {time: 30, unit: FuzzyTime.Unit.SECOND}, ... ]- Source:
-
at(format, delta)
-
Configure this FuzzyTime to return the given string format (with values plugged in) when FuzzyTime#build is called and the given time delta has been reached.
Parameters:
Name Type Description formatstring The string format
deltastring | list The time delta at which to display. This can be either an ISO 8601 Duration (string) or a list of maps like:
[ {time: 1, unit: FuzzyTime.Unit.MINUTE}, {time: 30, unit: FuzzyTime.Unit.SECOND}, ... ]- Source:
-
before(format, delta)
-
Configures this FuzzyTime instance to return the given string format (with values plugged in) any time FuzzyTime#build is called and before the given time delta has passed.
Parameters:
Name Type Description formatstring The string format
deltastring | list The time delta at which to display. This can be either an ISO 8601 Duration (string) or a list of maps like:
[ {time: 1, unit: FuzzyTime.Unit.MINUTE}, {time: 30, unit: FuzzyTime.Unit.SECOND}, ... ]- Source:
-
build(date, referenceDate) → {string}
-
Build a "fuzzy" interpretation of the difference between the provided dates based on previous configurations (using FuzzyTime#at, FuzzyTime#before, and FuzzyTime#after).
Parameters:
Name Type Argument Description datedate The starting date
referenceDatedate <optional>
The ending date. If nothing is provided for this parameter, it defaults to now (i.e. new Date()).
- Source:
Returns:
The "fuzzy" timestamp for the differene between the two provided dates (if only one date is provided, now is used for second date). If there is no "at", "before", or "after" configuration that applies to the difference between the dates provided, the locale string of the date parameter is provided.
- Type
- string