1. Date and time functions

1.1. datevalue

datevalue(text, format?, locale?)

Converts text to a date. Unless format is specified, the date must be represented using the ISO 8601 format (also used by W3C XML Schema Datatypes).

Date format format may be used to parse text using a localized format. Supported formats are described in http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html. The empty string ("") specifies the default format.

Locale locale may be used to specify how to interpret format format. Without locale argument locale, this format is interpreted using the current language of the XML document (typically specified using the standard xml:lang attribute, but this can be configured).

Locales are specified using a standard 2-letter language code, optionally followed by a dash and a standard 2-letter country code. Examples: en, en-US, de, de-CH, etc.

Examples, (assume that the language of the XML document being edited is "en-US" and that XMLmind XML Editor is running on a machine in France=GMT+1):

  • datevalue("1960-03-16Z") = March 16, 1960 UTC1960-03-16Z

  • datevalue("03/16/60", "") = 1960-03-15Z

  • datevalue("03/16/60 UTC", "MM/dd/yy z") = 1960-03-16Z

  • datevalue("16/03/60", "", "fr") =1960-03-15Z

  • datevalue("16 Mars 1960", "dd MMMM yyyy", "fr") = 1960-03-15Z

datevalue can also be used to convert a number to a date. In such case, format must not be specified. A date can be represented by the number of seconds since January 1, 1970, 00:00:00 GMT.

Example: datevalue(-309139200.000) = March 16, 1960 UTC

See also timevalue, datetimevalue, numbervalue, text.

1.2. timevalue

timevalue(text, format?, locale?)

Converts text to a time. Unless format is specified, the time must be represented using the ISO 8601 format (also used by W3C XML Schema Datatypes).

Date/time format format may be used to parse text using a localized format. Supported formats are described in http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html. The empty string ("") specifies the default format.

Locale locale may be used to specify how to interpret format format. Without locale argument locale, this format is interpreted using the current language of the XML document (typically specified using the standard xml:lang attribute, but this can be configured).

Locales are specified using a standard 2-letter language code, optionally followed by a dash and a standard 2-letter country code. Examples: en, en-US, de, de-CH, etc.

Examples, (assume that the language of the XML document being edited is "en-US" and that XMLmind XML Editor is running on a machine in France=GMT+1):

  • timevalue("13:30:00Z") = 13:30:00Z

  • timevalue("13:30:00") = 12:30:00Z

  • timevalue("01:30 pm", "") = 12:30:00Z

  • timevalue("01:30:00 pm UTC", "hh:mm:ss a z") = 13:30:00Z

  • timevalue("13:30", "", "fr") = 12:30:00Z

  • timevalue("13:30:00.123", "HH:mm:ss.SSS", "fr") = 12:30:00.123Z

timevalue can also be used to convert a number to a time. In such case, format must not be specified. A time can be represented by the number of seconds since 00:00:00 GMT.

Example: timevalue(13.5*3600) = T13:30:00Z

See also datevalue, datetimevalue, numbervalue, text.

1.3. datetimevalue

datetimevalue(text, format?, locale?)

Converts text to a date+time. Unless format is specified, the date+time must be represented using the ISO 8601 format (also used by W3C XML Schema Datatypes).

Date/time format format may be used to parse text using a localized format. Supported formats are described in http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html. The empty string ("") specifies the default format.

Locale locale may be used to specify how to interpret format format. Without locale argument locale, this format is interpreted using the current language of the XML document (typically specified using the standard xml:lang attribute, but this can be configured).

Locales are specified using a standard 2-letter language code, optionally followed by a dash and a standard 2-letter country code. Examples: en, en-US, de, de-CH, etc.

Examples, (assume that the language of the XML document being edited is "en-US" and that XMLmind XML Editor is running on a machine in France=GMT+1):

  • datetimevalue("1960-03-16T13:30:00Z") = 1960-03-16T13:30:00Z

  • datetimevalue("03/16/1960 01:30 pm", "") = 1960-03-16T12:30:00Z

  • datetimevalue("03/16/60 01:30:00 pm UTC", "MM/dd/yy hh:mm:ss a z") = 1960-03-16T13:30:00Z

  • datetimevalue("16/03/60 13:30", "", "fr") =1960-03-16T12:30:00Z

  • datetimevalue("13:30:00, 16 Mars 1960", "HH:mm:ss, dd MM yyy", "fr") = 1960-03-16T12:30:00Z

datetimevalue can also be used to convert a number to a date+time. In such case, format must not be specified. A date+time can be represented by the number of seconds since January 1, 1970, 00:00:00 GMT.

Example: datetimevalue(-309139200 + 13.5*3600) = 1960-03-16T13:30:00Z

See also datevalue, timevalue, numbervalue, text.

1.4. date

date(year, month, day, time_zone?)

Returns a date representing specified year, month, day. Unless time_zone is specified, the local time zone is used.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • date(1960, 03, 16) = 1960-03-15Z

  • date(1960, 03, 16, "GMT+01:00") = 1960-03-15Z

  • date(1960, 03, 16, "GMT") = 1960-03-16Z

Specifying time zones is explained in this document http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html.

See also datevalue, timevalue, datetimevalue, time, datetime.

1.5. time

time(hour, minute, second, time_zone?)

Returns a time representing specified hour, minute, second. Unless time_zone is specified, the local time zone is used.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • time(13, 30, 45) = 12:30:45Z

  • time(13, 30, 45, "GMT-01:00") = 14:30:45Z

  • time(13, 30, 45.123, "GMT") = 13:30:45Z (note that seconds have been rounded)

Specifying time zones is explained in this document http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html.

See also datevalue, timevalue, datetimevalue, date, datetime.

1.6. datetime

datetime(year, month, day, hour, minute, second, time_zone?)

Returns a date+time representing specified year, month, day, hour, minute, second. Unless time_zone is specified, the local time zone is used.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • datetime(1960, 03, 16, 13, 30, 45) = 1960-03-16T12:30:45Z

  • datetime(1960, 03, 16, 13, 30, 45, "GMT-01:00") = 1960-03-16T14:30:45Z

  • datetime(1960, 03, 16, 13, 30, 45, "GMT") = 1960-03-16T13:30:45Z

Specifying time zones is explained in this document http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html.

See also datevalue, timevalue, datetimevalue, date, time.

1.7. year

year(date)

Returns the year in specified date, a date or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • year(date(1960,03,16)) = 1960

  • year(date(1960,03,16, "UTC")) = 1960

  • year("1960-03-16T13:30:45+01:00") = 1960

  • year("1960-12-31T23:00:00Z") = 1961

See also month, day, weekday, hour, minute, second.

1.8. month

month(date)

Returns the month in specified date, a date or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • month(date(1960,03,16)) = 3

  • month(date(1960,03,16, "UTC")) = 3

  • month("1960-03-16T13:30:45+01:00") = 3

  • month("1960-03-31T23:00:00Z") = 4

See also year, day, weekday, hour, minute, second.

1.9. day

day(date)

Returns the day in specified date, a date or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • day(date(1960,03,16)) = 16

  • day(date(1960,03,16, "UTC")) = 16

  • day("1960-03-16T13:30:45+01:00") = 16

  • day("1960-03-16T23:00:00Z") = 17

See also year, month, weekday, hour, minute, second.

1.10. weekday

weekday(date, option?)

Returns the day in specified date, a date or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

OptionDescription
1 (default)Returns 1 for Sunday to 7 for Saturday.
2Returns 1 for Monday to 7 for Sunday
3Returns 0 for Monday to 6 for Sunday

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • weekday(date(1960,03,16)) = 4 (Wednesday)

  • weekday(date(1960,03,16, "UTC")) = 4

  • weekday("1960-03-16T13:30:45+01:00") = 4

  • weekday("1960-03-16T23:00:00Z") = 5 (Thursday)

With option=2:

  • weekday(date(1960,03,16), 2) = 3 (Wednesday)

  • weekday(date(1960,03,16, "UTC"), 2) = 3

  • weekday("1960-03-16T13:30:45+01:00", 2) = 3

  • weekday("1960-03-16T23:00:00Z", 2) = 4 (Thursday)

With option=3:

  • weekday(date(1960,03,16), 3) = 2 (Wednesday)

  • weekday(date(1960,03,16, "UTC"), 3) = 2

  • weekday("1960-03-16T13:30:45+01:00", 3) = 2

  • weekday("1960-03-16T23:00:00Z", 3) = 3 (Thursday)

See also year, month, day, hour, minute, second.

1.11. hour

hour(date)

Returns the hours in specified date, a time or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • hour(time(13,30,45)) = 13

  • hour(time(13,30,45, "UTC")) = 14

  • hour("1960-03-16T13:30:45+01:00") = 13

  • hour("1960-03-16T13:30:45.123") = 13

  • hour("1960-03-16T13:30:45.123Z") = 14

See also year, month, day, weekday, minute, second.

1.12. minute

minute(date)

Returns the minutes in specified date, a time or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • minute(time(13,30,45)) = 30

  • minute("1960-03-16T13:30:45+01:00") = 30

See also year, month, day, weekday, hour, second.

1.13. second

second(date)

Returns the seconds in specified date, a time or date+time. This function uses the local calendar (i.e. local time zone) to compute its result.

Examples (XMLmind XML Editor running on a machine in France=GMT+1):

  • second(time(13,30,45)) = 45

  • second("1960-03-16T13:30:45.123") = 45 (note that seconds are rounded)

See also year, month, day, weekday, hour, minute.

1.14. today

today()

Returns current date. The time zone used is the local time zone.

Example (XMLmind XML Editor running on a machine in France=GMT+1): today() = 2004-10-15Z

1.15. now

now()

Returns current date+time. The time zone used is the local time zone.

Example (XMLmind XML Editor running on a machine in France=GMT+1): now() = 2004-10-16T11:12:14.155Z