goog.date.relative
Functions
format( dateMs ) → string
string
formatDay( dateMs, opt_formatter ) → string
string
formatPast( dateMs ) → string
string
Accepts a timestamp in milliseconds and outputs a relative time in the form of "1 hour ago", "1 day ago". All future times will be returned as 0 minutes ago.
This is provided for compatibility with users of the previous incarnation of the above #format method who relied on it protecting against future dates.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getDateString( date, opt_shortTimeMsg, opt_fullDateMsg ) → string
string
Formats a date, adding the relative date in parenthesis. If the date is less than 24 hours then the time will be printed, otherwise the full-date will be used. Examples: 2:20 PM (1 minute ago) Monday, February 27, 2009 (4 days ago) Tuesday, March 20, 2005 // Too long ago for a relative date.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
getPastDateString( date, opt_shortTimeMsg, opt_fullDateMsg ) → string
string
Formats a date, adding the relative date in parenthesis. Functions the same as #getDateString but ensures that the date is always seen to be in the past. If the date is in the future, it will be shown as 0 minutes ago.
This is provided for compatibility with users of the previous incarnation of the above #getDateString method who relied on it protecting against future dates.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
setCasingMode( capitalizeMode ) → void
void
Sets casing mode to a boolean. If true, the first letter of day formats ("today", "yesterday", "tommorow") is capitalized using locale-aware toUpper. If false, no casing is done on basic data.
Parameters |
|
---|
setTimeDeltaFormatter( formatter ) → void
void
Sets a different formatting function for time deltas ("3 days ago"). While its visibility is public, this function is Closure-internal and should not be used in application code.
Parameters |
|
---|
upcase( text ) → string
string
Properties
TimeDeltaFormatter → function(number, boolean, goog.date.relative.Unit): string
function(number, boolean, goog.date.relative.Unit): string
Caller-settable function for formatting time. Default is internal formatting using goog.i18n.RelativeDateTimeFormat