Module: alfresco/core/TemporalUtils

alfresco/core/TemporalUtils

This is a mixin that provides time and date related utility functions.
Author:
  • Richard Smith
License:
Source:

Members

i18nRequirements :object[]

An array of the i18n files to use with this widget.
Type:
  • object[]
Default Value:
  • [{i18nFile: "./i18n/TemporalUtils.properties"}]
Source:

Methods

formatDate(date, format) → {String}

Formats a date time into a more UI-friendly format
Parameters:
Name Type Argument Description
date String | Date <optional>
Date as ISO8601 compatible string or JavaScript Date Object. Today used if missing.
format String <optional>
Mask to use to override default.
Source:
Returns:
Date formatted for UI
Type
String

formatDate3rd() → {String}

Format a date object to a user-specified mask Original code: Date Format 1.1 (c) 2007 Steven Levithan MIT license With code by Scott Trenda (Z and o flags, and enhanced brevity) http://blog.stevenlevithan.com/archives/date-time-format
Source:
Returns:
Type
String

fromISO8601(date, ignoreTime) → {Date}

Convert an ISO8601 date string into a native JavaScript Date object
Parameters:
Name Type Argument Description
date String ISO8601 formatted date string
ignoreTime Boolean <optional>
Ignores any time (and therefore timezone) components.
Source:
Returns:
JavaScript native Date object or null on errors
Type
Date

getRelativeTime(from, to) → {String}

Generate a relative time between two Date objects.
Parameters:
Name Type Argument Description
from Date | String JavaScript Date object or ISO8601-formatted date string
to Date | String <optional>
JavaScript Date object or ISO8601-formatted date string, defaults to now if not supplied
Source:
Returns:
Relative time description
Type
String

parseTime(timeString) → {Date}

Converts a user input time string into a date object. Accepted inputs include: 11am, 11PM, 11:00, 23:00, 11:23 am, 3 p.m., 08:00, 1100, 11, 8, 23. Only accepts hours and minutes. Seconds are zeroed.
Parameters:
Name Type Description
timeString String User input time
Source:
Returns:
Type
Date

renderRelativeTime(id)

Render relative dates on the client Converts all ISO8601 dates within the specified container to relative dates. (indicated by {date.iso8601})
Parameters:
Name Type Description
id String ID of HTML element containing dates for conversion
Source:

toISO8601(date) → {String}

Convert a native JavaScript Date object into an ISO8601 date string
Parameters:
Name Type Description
date Date JavaScript native Date object
Source:
Returns:
ISO8601 formatted date string
Type
String

<inner> constructor(config)

Constructor
Parameters:
Name Type Description
config object Config to mixin
Source: