Simple concept to facilitate the work with dates. Because on the World
Wide Web there is no common denominator between date representation
this concept has the purpose to assist the user in parsing and
formatting dates. To specify the time format use a time pattern string.
In this pattern, all ASCII letters are reserved as pattern letters,
which are defined as the following:
Symbol Meaning Presentation Example
------ ------- ------------ -------
G era designator (Text) AD
y year (Number) 1996
M month in year (Text & Number) July & 07
d day in month (Number) 10
h hour in am/pm (1~12) (Number) 12
H hour in day (0~23) (Number) 0
m minute in hour (Number) 30
s second in minute (Number) 55
S millisecond (Number) 978
E day in week (Text) Tuesday
D day in year (Number) 189
F day of week in month (Number) 2 (2nd Wed in July)
w week in year (Number) 27
W week in month (Number) 2
a am/pm marker (Text) PM
k hour in day (1~24) (Number) 24
K hour in am/pm (0~11) (Number) 0
z time zone (Text) Pacific Standard Time
' escape for text (DelimiMerlinter)
'' single quote (Literal) '
For day and month representation, the Date concept uses the default
locale. if other locales are desired the equivalent methods can be used,
methods that allow the specification of a particular desired locale.
Displaing the current date
print Date.getToday.toTXT
-- the result is --
Tue Apr 23 12:28:40 EEST 2002
Parsing and reformating a date
$date = Date.create("MMM d, ''yy", "July 10, '96")
PRINT $date.getDate("EEE, d MMM yyyy")
-- the result is --
Wed, 10 Jul 1996
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Parameters: |
date : | The value with which the new Date will be created. |
|
Constructor which creates a new Date instance from the Integer parameter
passed in. The parameter must represent the number of miliseconds after
January, 1, 1970, 00:00:00 GMT.
Parameters: |
$pattern : | The pattern for the given date. |
$date : | The value with which the new Date will be created. |
|
Constructor which creates a new Date instance by parsing the value of
the date using the parse rule defined by the pattern. The pattern can be
formated using the date attoms.
Parameters: |
$pattern : | The pattern for the date to set. |
$locale : | The locale which the Date will use to represent the
date. Country specific values for day, month and so
on. |
$date : | The new date to be set. |
|
Creates a new Date instance by parsing the value of the $date String
using the parse rule defined by the $pattern parameter. The
pattern date format atoms described at the top of this page.
The $locale parameter specifies that the values of the pattern
atoms will be expected to conform with the proper locale
parameter.
This method is especially useful when the date we want to parse
is in a format different than the one specified by our own locale.
In other words, usually if you try to parse a date containing textual
month or day representation form other countries.
$val = "(Miercuri) 17 Septembrie 2002" ## a date value in Romania
## containing the day (Miercuri) and
## the month Septembrie == September
## we parse the date into a date concept specifying that the value
## will be conform to the Romanian locale
$date = Date.create("(EEEEE) dd MMMM yyyy", Locale.create("RO", "ro"), $val)
print $date
-- the result is --
Tue Sep 17 00:00:00 EEST 2002
Tests if this date is before the specified date.
Returns true if and only if the instant of time
represented by this Date concept is strictly earlier than
the instant represented by when; false otherwise.
Tests if this date is after the specified date.
Returns true if and only if the instant of time
represented by this Date concept is strictly later than
the instant represented by when; false otherwise.
Tests if this date is after the specified date.
Compares two dates for equality. The result is true if
and only if the argument is a Date concept that
represents the same point in time, to the millisecond,
as this concept.
Parameters: |
$pattern : | The pattern for the returned date. |
|
Returns a string representing the date value of this concept. The
returned string is formated conform the specified pattern.
$today = Date.getToday
print $today.getDate("yyyy/MM/dd")
-- the result is --
2002/07/15
Parameters: |
$pattern : | The pattern for the returned date. |
$locale : | The locale which the Date will use to represent the
date. Country specific values for day, month and so
on. |
|
Returns a string representing the date value of this concept. The
returned string is formated conform the specified pattern with the values
conforming with the given Locale.
$date typeof Date
# default locale (Romanian) in my case
print $date.getDate("MMMM, dd (EEEEE) yyyy")
# The same date with the French locale
print $date.getDate("MMMM, dd (EEEEE) yyyy", Locale.create("FR", "fr"))
# The same date with the US locale
print $date.getDate("MMMM, dd (EEEEE) yyyy", Locale.create("EN", "us"))
# The same date with the German locale
print $date.getDate("MMMM, dd (EEEEE) yyyy", Locale.create("DE", "de"))
-- the result is --
septembrie, 18 (miercuri) 2002
septembre, 18 (mercredi) 2002
September, 18 (Wednesday) 2002
September, 18 (Mittwoch) 2002
Returns the number of milliseconds since January
1, 1970, 00:00:00 GMT represented by this Date object.
$today = Date.getToday
print $today.getTime
-- the result is --
1026986843434
Returns an instance of a Date concept representing the today's date.
$today = Date.getToday
print $today.getDate("yyyy/MM/dd")
-- the result is --
2002/07/15
Parameters: |
$date : | The new date to be set. |
|
Sets the date to the specified value.
$today = Date.getToday
print $today.getDate("yyyy/MM/dd")
$date typeof Date
$date.setDate($today.getTime)
print $date.getDate("yyyy/MM/dd")
-- the result is --
2002/07/15
2002/07/15
Parameters: |
$pattern : | The pattern for the date to set. |
$date : | The new date to be set. |
|
Set the value of date by parsing the value of the date using the parse
rule defined by the pattern. The pattern can be formated using the date
atoms.
$date typeof Date
$date.setDate("yyyy/MM/dd", "2002/05/19")
print $date.getDate("yyyy/MM/dd")
-- the result is --
2002/05/19
Parameters: |
$pattern : | The pattern for the date to set. |
$locale : | The locale which the Date will use to represent the
date. Country specific values for day, month and so
on. |
$date : | The new date to be set. |
|
Set the value of date by parsing the value of the $date String
using the parse rule defined by the $pattern parameter. The
pattern date format atoms described at the top of this page.
The $locale parameter specifies that the values of the pattern
atoms will be expected to conform with the proper locale
parameter.
This method is especially useful when the date we want to parse
is in a format different than the one specified by our own locale.
In other words, usually if you try to parse a date containing textual
month or day representation form other countries.
$val = "(Miercuri) 17 Septembrie 2002" ## a date value in Romania
$date typeof Date ## containing the day (Miercuri) and
## the month Septembrie == September
## we parse the date into a date concept specifying that the value
## will be conform to the Romanian locale
$date.setDate("(EEEEE) dd MMMM yyyy", Locale.create("RO", "ro"), $val)
print $date
-- the result is --
Tue Sep 17 00:00:00 EEST 2002
Returns a stream representing the simple text rendering of this concept.
print Date.getToday.toTXT
-- the result is --
Thu Jul 18 13:24:08 EEST 2002
Returns a stream representing the XML rendering of this concept.
print Date.getToday.toXML
-- the result is --
Thu Jul 18 13:24:08 EEST 2002