Alternate Date constructor which understands many different text formats,
a timestamp, or another date.
method
Date.create(, [locale] = currentLocale)
extra
If no argument is given, date is assumed to be now. %Date.create% additionally
can accept enumerated parameters as with the standard date constructor. [locale]
can be passed to specify the locale that the date is in. When unspecified, the
current locale (default is English) is assumed. UTC-based dates can be created
through the %utc% object. For more see @date_format.
set
Date.utc.create
example
Date.create('July') -> July of this year
Date.create('1776') -> 1776
Date.create('today') -> today
Date.create('wednesday') -> This wednesday
Date.create('next friday') -> Next friday
Date.create('July 4, 1776') -> July 4, 1776
Date.create(-446806800000) -> November 5, 1955
Date.create(1776, 6, 4) -> July 4, 1776
Date.create('1776?07?04?', 'ja') -> July 4, 1776
Date.utc.create('July 4, 1776', 'en') -> July 4, 1776
Parameters
locale?: stringoptional
Locale to create the date in, default = currentLocale.
Returns
Date
Date
public create(d: string, locale?: string): Date
see
create
Parameters
d: string
Human readable date to convert to a Date object.
locale?: stringoptional
Returns
Date
public create(year: number, month: number, day: number, locale?: string): Date
see
create
Parameters
year: number
Year YYYY
month: number
Month MM
day: number
Day DD
locale?: stringoptional
Returns
Date
public future(d: string, locale?: string): Date
Alternate form of %Date.create% with any ambiguity assumed to be the future.
method
Date.future(, [locale] = currentLocale)
extra
For example %"Sunday"% can be either "the Sunday coming up" or "the Sunday last"
depending on context. Note that dates explicitly in the past ("last Sunday") will
remain in the past. This method simply provides a hint when ambiguity exists. UTC
-based dates can be created through the %utc% object. For more, see @date_format.
set
Date.utc.future
example
Date.future('July') -> July of this year or next depending on the current month
Date.future('Wednesday') -> This wednesday or next depending on the current weekday
Parameters
d: string
Future human redable date to convert to a Date object.
locale?: stringoptional
Locale to create the date in, default = currentLocale.
Returns the number of milliseconds since January 1st, 1970 00:00:00 (UTC time).
method
Date.now()
extra
Provided for browsers that do not support this method.
example
Date.now() -> ex. 1311938296231
Returns
string
String
public past(d: string, local?: string): Date
Alternate form of %Date.create% with any ambiguity assumed to be the past.
method
Date.past(, [locale] = currentLocale)
extra
For example %"Sunday"% can be either "the Sunday coming up" or "the Sunday last" depending
on context. Note that dates explicitly in the future ("next Sunday") will remain in the future.
This method simply provides a hint when ambiguity exists. UTC-based dates can be created
through the %utc% object. For more, see @date_format.
set
Date.utc.past
example
Date.past('July') -> July of this year or last depending on the current month
Date.past('Wednesday') -> This wednesday or last depending on the current weekday
Parameters
d: string
Past human readable date to convert to a Date object.
Sugar has support for 13 locales that are available through the
"Date Locales" package. In addition you can define a new locale with
%Date.addLocale%. For more see @date_format.