date.relative

Classes


Public Protected Private

Enumerations

goog.date.relative.Unit :
Enumeration used to identify time units internally.
Constants:
DAYS
No description.
HOURS
No description.
MINUTES
No description.
Code »

Global Functions

goog.date.relative.format(dateMs) string
Accepts a timestamp in milliseconds and outputs a relative time in the form of "1 hour ago", "1 day ago", "in 1 hour", "in 2 days" etc. If the date delta is over 2 weeks, then the output string will be empty.
Arguments:
dateMs : number
Date in milliseconds.
Returns: string  The formatted date.
code »
goog.date.relative.formatDay(dateMsopt_formatter) string
Accepts a timestamp in milliseconds and outputs a relative day. i.e. "Today", "Yesterday", "Tomorrow", or "Sept 15".
Arguments:
dateMs : number
Date in milliseconds.
opt_formatter : function(!Date):string=
Formatter for the date. Defaults to form 'MMM dd'.
Returns: string  The formatted date.
code »
goog.date.relative.formatFullDate_(date) string
Returns a date in full date format, e.g. Tuesday, March 24, 2009.
Arguments:
date : Date | goog.date.DateTime
The date object.
Returns: string  The formatted string.
code »
goog.date.relative.formatMonth_(date) string
Returns a date in month format, e.g. Mar 15.
Arguments:
date : Date
The date object.
Returns: string  The formatted string.
code »
goog.date.relative.formatPast(dateMs) 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 method who relied on it protecting against future dates.
Arguments:
dateMs : number
Date in milliseconds.
Returns: string  The formatted date.
code »
goog.date.relative.formatShortTime_(date) string
Returns a date in short-time format, e.g. 2:50 PM.
Arguments:
date : Date | goog.date.DateTime
The date object.
Returns: string  The formatted string.
code »
goog.date.relative.formatTimeDelta_()
Handles formatting of time deltas.
code »
goog.date.relative.getDateString(dateopt_shortTimeMsgopt_fullDateMsg) 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.
Arguments:
date : Date | goog.date.DateTime
A date object.
opt_shortTimeMsg : string=
An optional short time message can be provided if available, so that it's not recalculated in this function.
opt_fullDateMsg : string=
An optional date message can be provided if available, so that it's not recalculated in this function.
Returns: string  The date string in the above form.
code »
goog.date.relative.getDateString_(daterelativeFormatteropt_shortTimeMsgopt_fullDateMsg) 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.
Arguments:
date : Date | goog.date.DateTime
A date object.
relativeFormatter : function(number) : string
Function to use when formatting the relative date.
opt_shortTimeMsg : string=
An optional short time message can be provided if available, so that it's not recalculated in this function.
opt_fullDateMsg : string=
An optional date message can be provided if available, so that it's not recalculated in this function.
Returns: string  The date string in the above form.
code »
goog.date.relative.getMessage_(deltafutureunit) string
Gets a localized relative date string for a given delta and unit.
Arguments:
delta : number
Number of minutes/hours/days.
future : boolean
Whether the delta is in the future.
unit : goog.date.relative.Unit
The units the delta is in.
Returns: string  The message.
code »
goog.date.relative.getPastDateString(dateopt_shortTimeMsgopt_fullDateMsg) 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 method who relied on it protecting against future dates.
Arguments:
date : Date | goog.date.DateTime
A date object.
opt_shortTimeMsg : string=
An optional short time message can be provided if available, so that it's not recalculated in this function.
opt_fullDateMsg : string=
An optional date message can be provided if available, so that it's not recalculated in this function.
Returns: string  The date string in the above form.
code »
goog.date.relative.setTimeDeltaFormatter(formatter)
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.
Arguments:
formatter : goog.date.relative.TimeDeltaFormatter
The function to use for formatting time deltas (i.e. relative times).
code »

Global Properties

goog.date.relative.DAY_MS_ :
Number of milliseconds in a day.
Code »
goog.date.relative.MINUTE_MS_ :
Number of milliseconds in a minute.
Code »
goog.date.relative.TimeDeltaFormatter :
No description.
Code »
goog.date.relative.fullDateFormatter_ : goog.i18n.DateTimeFormat
Full date formatter.
Code »
goog.date.relative.monthDateFormatter_ : goog.i18n.DateTimeFormat
Month-date formatter.
Code »
goog.date.relative.shortTimeFormatter_ : goog.i18n.DateTimeFormat
Short time formatter.
Code »

Package date

Package Reference