Class Date
- java.lang.Object
-
- net.sf.saxon.option.exslt.Date
-
public final class Date extends java.lang.Object
This class implements extension functions in the http://exslt.org/dates-and-times namespace.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
add(XPathContext context, java.lang.String datetimeIn, java.lang.String durationIn)
The date:add function returns the date/time resulting from adding a duration to a date/time.java.lang.String
addDuration(java.lang.String duration0, java.lang.String duration1)
The date:add-duration function returns the duration resulting from adding two durations together.static java.lang.String
date(XPathContext context)
The date:date function returns the current date.static java.lang.String
date(XPathContext context, java.lang.String datetimeIn)
The date:date function returns the date specified in the date/time string given as the argument.static java.lang.String
dateTime(XPathContext context)
The date:date-time function returns the current date and time as a date/time string.static java.lang.String
dayAbbreviation(XPathContext context)
Return the day of the week given in the current date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.static java.lang.String
dayAbbreviation(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.static double
dayInMonth(XPathContext context)
Return the day number of the current date within the monthstatic double
dayInMonth(XPathContext context, java.lang.String dateTime)
Return the day number of a specified date within the monthstatic double
dayInWeek(XPathContext context)
Return the day of the week in the current date as a number.static double
dayInWeek(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as a number.static double
dayInYear(XPathContext context)
Return the day number of the current date within the yearstatic double
dayInYear(XPathContext context, java.lang.String dateTime)
Return the day number of a specified date within the yearstatic java.lang.String
dayName(XPathContext context)
Return the day of the week given in the current date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.static java.lang.String
dayName(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.static double
dayOfWeekInMonth(XPathContext context)
Return the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).static double
dayOfWeekInMonth(XPathContext context, java.lang.String dateTime)
Return the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).static java.lang.String
difference(XPathContext context, java.lang.String dateLeftIn, java.lang.String dateRightIn)
The date:difference function returns the duration between the first date and the second date.static java.lang.String
duration(double seconds)
The date:duration function returns a duration string representing the number of seconds specified by the argument string.static double
hourInDay(XPathContext context)
Return the current hour of the daystatic double
hourInDay(XPathContext context, java.lang.String dateTime)
Return the hour of the day in the specified date or date/timestatic boolean
leapYear(XPathContext context)
Returns true if the current year is a leap yearstatic boolean
leapYear(XPathContext context, java.lang.String dateTime)
Return true if the year specified in the date/time string given as the argument is a leap year.static double
minuteInHour(XPathContext context)
Return the current minute of the hourstatic double
minuteInHour(XPathContext context, java.lang.String dateTime)
Return the minute of the hour in the specified date or date/timestatic java.lang.String
monthAbbreviation(XPathContext context)
Return the month abbreviation from the current date.static java.lang.String
monthAbbreviation(XPathContext context, java.lang.String date)
Return the month abbreviation from a date.static double
monthInYear(XPathContext context)
Return the month number from the current date.static double
monthInYear(XPathContext context, java.lang.String dateTime)
Return the month number from a date.static java.lang.String
monthName(XPathContext context)
Return the month name from the current date.static java.lang.String
monthName(XPathContext context, java.lang.String date)
Return the month name from a date.static double
secondInMinute(XPathContext context)
Return the current second of the minutestatic double
secondInMinute(XPathContext context, java.lang.String dateTime)
Return the second of the minute in the specified date or date/timestatic double
seconds(XPathContext context)
Return the number of seconds since 1 Jan 1970static double
seconds(XPathContext context, java.lang.String datetimeIn)
The date:seconds function returns the number of seconds specified by the argument string.static java.lang.String
sum(SequenceIterator durations)
The date:sum function adds a set of durations together.static java.lang.String
time(XPathContext context)
The date:time function returns the current time.static java.lang.String
time(XPathContext context, java.lang.String dateTime)
The date:time function returns the time specified in the date/time string given as the argument.static double
weekInMonth(XPathContext context)
Return the ISO week number of the current date within the monthstatic double
weekInMonth(XPathContext context, java.lang.String dateTime)
Return the week number of a specified date within the month (Note, this function is underspecified in EXSLT)static double
weekInYear(XPathContext context)
Return the ISO week number of the current date (Note, this returns the ISO week number: the result in EXSLT is underspecified)static double
weekInYear(XPathContext context, java.lang.String dateTime)
Return the ISO week number of a specified date within the year (Note, this returns the ISO week number: the result in EXSLT is underspecified)static double
year(XPathContext context)
The date:year function returns the current year.static double
year(XPathContext context, java.lang.String datetimeIn)
The date:year function returns the year of a date as a number.
-
-
-
Method Detail
-
dateTime
public static java.lang.String dateTime(XPathContext context) throws XPathException
The date:date-time function returns the current date and time as a date/time string.The date/time string that's returned must be a string in the format defined as the lexical representation of xs:dateTime in [3.2.7 dateTime] of [XML Schema Part 2: Datatypes].
The date/time format is basically CCYY-MM-DDThh:mm:ss+hh:mm.
The date/time string format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - followed by the difference between the difference from UTC represented as hh:mm.
- Parameters:
context
- the XPath dynamic context- Returns:
- the current date and time as a date/time string
- Throws:
XPathException
- if the context does not allow a date and time to be obtained
-
date
public static java.lang.String date(XPathContext context, java.lang.String datetimeIn)
The date:date function returns the date specified in the date/time string given as the argument. If no argument is given, then the current local date/time, as returned by date:date-time is used as a default argument.The date/time string that's returned must be a string in the format defined as the lexical representation of xs:dateTime in [3.2.7 dateTime] of [XML Schema Part 2: Datatypes].
If the argument is not in either of these formats, date:date returns an empty string ('').
The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult [XML Schema Part 2: Datatypes] and [ISO 8601] for details.
The date is returned as a string with a lexical representation as defined for xs:date in [3.2.9 date] of [XML Schema Part 2: Datatypes]. The date format is basically CCYY-MM-DD, although implementers should consult [XML Schema Part 2: Datatypes] and [ISO 8601] for details. If no argument is given or the argument date/time specifies a time zone, then the date string format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - followed by the difference between the difference from UTC represented as hh:mm. If an argument is specified and it does not specify a time zone, then the date string format must not include a time zone.
- Parameters:
context
- the XPath dynamic contextdatetimeIn
- the date and time as a date/time string- Returns:
- the date part of the dateTime supplied, or "" if invalid
-
date
public static java.lang.String date(XPathContext context) throws XPathException
The date:date function returns the current date.- Parameters:
context
- the XPath dynamic context- Returns:
- the current date as a string
- Throws:
XPathException
- if the context does not allow the date and time to be established
-
time
public static java.lang.String time(XPathContext context, java.lang.String dateTime)
The date:time function returns the time specified in the date/time string given as the argument.- Parameters:
context
- the XPath dynamic contextdateTime
- must start with [+|-]CCYY-MM-DDThh:mm:ss- Returns:
- the time part of the string, or "" if invalid
-
time
public static java.lang.String time(XPathContext context) throws XPathException
The date:time function returns the current time.- Parameters:
context
- the XPath dynamic context- Returns:
- the current time as a string
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
year
public static double year(XPathContext context, java.lang.String datetimeIn)
The date:year function returns the year of a date as a number. If no argument is given, then the current local date/time, as returned by date:date-time is used as a default argument.The date/time string specified as the first argument must be a right-truncated string in the format defined as the lexical representation of xs:dateTime in one of the formats defined in [XML Schema Part 2: Datatypes].
The permitted formats are as follows:
- xs:dateTime (CCYY-MM-DDThh:mm:ss)
- xs:date (CCYY-MM-DD)
- xs:gYearMonth (CCYY-MM)
- xs:gYear (CCYY)
If the date/time string is not in one of these formats, then NaN is returned.
Note: although not specifically permitted in the EXSLT specification, the Saxon implementation also allows the input value to contain a timezone
- Parameters:
context
- the XPath dynamic contextdatetimeIn
- the supplied date/time in ISO format- Returns:
- the year component of the supplied date time, or NaN if invalid
-
year
public static double year(XPathContext context) throws XPathException
The date:year function returns the current year.- Parameters:
context
- the XPath dynamic context- Returns:
- the current year as a double
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
leapYear
public static boolean leapYear(XPathContext context, java.lang.String dateTime)
Return true if the year specified in the date/time string given as the argument is a leap year.- Parameters:
context
- the XPath dynamic contextdateTime
- a dateTime as a string- Returns:
- true if the year is a leap year (false if not, or if input is invalid)
-
leapYear
public static boolean leapYear(XPathContext context) throws XPathException
Returns true if the current year is a leap year- Parameters:
context
- the XPath dynamic context- Returns:
- true if the current year is a leap year (false if not, or if input is invalid)
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
monthInYear
public static double monthInYear(XPathContext context, java.lang.String dateTime)
Return the month number from a date. The date must start with either "CCYY-MM" or "--MM"- Parameters:
context
- the XPath dynamic contextdateTime
- a dateTime as a string- Returns:
- the month extracted from the dateTime
-
monthInYear
public static double monthInYear(XPathContext context) throws XPathException
Return the month number from the current date.- Parameters:
context
- the XPath dynamic context- Returns:
- the current month number
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
monthName
public static java.lang.String monthName(XPathContext context, java.lang.String date)
Return the month name from a date. The date must start with either "CCYY-MM" or "--MM"- Parameters:
context
- the XPath dynamic contextdate
- the date/time as a string- Returns:
- the English month name, for example "January", "February"
-
monthName
public static java.lang.String monthName(XPathContext context) throws XPathException
Return the month name from the current date.- Parameters:
context
- the XPath dynamic context- Returns:
- the English month name, for example "January", "February"
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
monthAbbreviation
public static java.lang.String monthAbbreviation(XPathContext context, java.lang.String date)
Return the month abbreviation from a date.- Parameters:
context
- the XPath dynamic contextdate
- The date must start with either "CCYY-MM" or "--MM"- Returns:
- the English month abbreviation, for example "Jan", "Feb"
-
monthAbbreviation
public static java.lang.String monthAbbreviation(XPathContext context) throws XPathException
Return the month abbreviation from the current date.- Parameters:
context
- the XPath dynamic context- Returns:
- the English month abbreviation, for example "Jan", "Feb"
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
weekInYear
public static double weekInYear(XPathContext context, java.lang.String dateTime)
Return the ISO week number of a specified date within the year (Note, this returns the ISO week number: the result in EXSLT is underspecified)- Parameters:
context
- the XPath dynamic contextdateTime
- the current date starting CCYY-MM-DD- Returns:
- the ISO week number
-
weekInYear
public static double weekInYear(XPathContext context) throws XPathException
Return the ISO week number of the current date (Note, this returns the ISO week number: the result in EXSLT is underspecified)- Parameters:
context
- the XPath dynamic context- Returns:
- the ISO week number
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
weekInMonth
public static double weekInMonth(XPathContext context, java.lang.String dateTime)
Return the week number of a specified date within the month (Note, this function is underspecified in EXSLT)- Parameters:
context
- the XPath dynamic contextdateTime
- the date starting CCYY-MM-DD- Returns:
- the week number within the month
-
weekInMonth
public static double weekInMonth(XPathContext context) throws XPathException
Return the ISO week number of the current date within the month- Parameters:
context
- the XPath dynamic context- Returns:
- the week number within the month
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayInYear
public static double dayInYear(XPathContext context, java.lang.String dateTime)
Return the day number of a specified date within the year- Parameters:
context
- the XPath dynamic contextdateTime
- the date starting with CCYY-MM-DD- Returns:
- the day number within the year, as a double
-
dayInYear
public static double dayInYear(XPathContext context) throws XPathException
Return the day number of the current date within the year- Parameters:
context
- the XPath dynamic context- Returns:
- the day number within the year, as a double
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayInMonth
public static double dayInMonth(XPathContext context, java.lang.String dateTime)
Return the day number of a specified date within the month- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DD, or --MM-DD, or ---DD- Returns:
- the day number within the month, as a double
-
dayInMonth
public static double dayInMonth(XPathContext context) throws XPathException
Return the day number of the current date within the month- Parameters:
context
- the XPath dynamic context- Returns:
- the current day number, as a double
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayOfWeekInMonth
public static double dayOfWeekInMonth(XPathContext context, java.lang.String dateTime)
Return the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DD- Returns:
- the the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).
-
dayOfWeekInMonth
public static double dayOfWeekInMonth(XPathContext context) throws XPathException
Return the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).- Parameters:
context
- the XPath dynamic context- Returns:
- the the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayInWeek
public static double dayInWeek(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as a number. The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday.- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DD- Returns:
- the day of the week as a number
-
dayInWeek
public static double dayInWeek(XPathContext context) throws XPathException
Return the day of the week in the current date as a number. The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday.- Parameters:
context
- the XPath dynamic context- Returns:
- the day of the week as a number
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayName
public static java.lang.String dayName(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DD- Returns:
- the English name of the day of the week
-
dayName
public static java.lang.String dayName(XPathContext context) throws XPathException
Return the day of the week given in the current date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.- Parameters:
context
- the XPath dynamic context- Returns:
- the English name of the day of the week
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
dayAbbreviation
public static java.lang.String dayAbbreviation(XPathContext context, java.lang.String dateTime)
Return the day of the week given in a date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DD- Returns:
- the English day abbreviation
-
dayAbbreviation
public static java.lang.String dayAbbreviation(XPathContext context) throws XPathException
Return the day of the week given in the current date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.- Parameters:
context
- the XPath dynamic context- Returns:
- the English day abbreviation
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
hourInDay
public static double hourInDay(XPathContext context, java.lang.String dateTime)
Return the hour of the day in the specified date or date/time- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the hour
-
hourInDay
public static double hourInDay(XPathContext context) throws XPathException
Return the current hour of the day- Parameters:
context
- the XPath dynamic context- Returns:
- the hour
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
minuteInHour
public static double minuteInHour(XPathContext context, java.lang.String dateTime)
Return the minute of the hour in the specified date or date/time- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the minute
-
minuteInHour
public static double minuteInHour(XPathContext context) throws XPathException
Return the current minute of the hour- Parameters:
context
- the XPath dynamic context- Returns:
- the minute
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
secondInMinute
public static double secondInMinute(XPathContext context, java.lang.String dateTime)
Return the second of the minute in the specified date or date/time- Parameters:
context
- the XPath dynamic contextdateTime
- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the second
-
secondInMinute
public static double secondInMinute(XPathContext context) throws XPathException
Return the current second of the minute- Parameters:
context
- the XPath dynamic context- Returns:
- the second
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
add
public static java.lang.String add(XPathContext context, java.lang.String datetimeIn, java.lang.String durationIn) throws XPathException
The date:add function returns the date/time resulting from adding a duration to a date/time. The first argument must be right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes].The permitted formats are as follows:
- xs:dateTime (CCYY-MM-DDThh:mm:ss)
- xs:date (CCYY-MM-DD)
- xs:gYearMonth (CCYY-MM)
- xs:gYear (CCYY)
The second argument is a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes].
The return value is a right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes] and listed above. This value is calculated using the algorithm described in [Appendix E Adding durations to dateTimes] of [XML Schema Part 2: Datatypes].
- Parameters:
context
- the XPath dynamic contextdatetimeIn
- the supplied date/time in ISO date/time formatdurationIn
- the supplied duration in ISO duration format- Returns:
- the result of the addition, as a string representing a dateTimeValue
- Throws:
XPathException
- if the supplied date or duration is invalid
-
sum
public static java.lang.String sum(SequenceIterator durations) throws XPathException
The date:sum function adds a set of durations together.The string values of the nodes in the node set passed as an argument are interpreted as durations and added together as if using the date:add-duration function. The string values of the nodes in the node set passed as the argument must be in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. If any of the string values of these nodes are not in this format, or if the node set is empty, the function returns an empty string (''). The result is a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes].
The durations can be summed by summing the numbers given for each of the components in the durations.
- Parameters:
durations
- a sequence which when atomized and converted to strings using the string() function yields a sequence of strings representing the input durations in ISO format- Returns:
- a string representation of the total duration, or "" if any input is invalid or if the input is an empty sequence
- Throws:
XPathException
- if the input sequence cannot be evaluated
-
addDuration
public java.lang.String addDuration(java.lang.String duration0, java.lang.String duration1)
The date:add-duration function returns the duration resulting from adding two durations together.Both arguments are strings in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. If either argument is not in this format, the function returns an empty string (''). The return value is a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. The durations can usually be added by summing the numbers given for each of the components in the durations. However, if the durations are differently signed, then this sometimes results in durations that are impossible to express in this syntax (e.g. 'P1M' + '-P1D'). In these cases, the function returns an empty string ('').
- Parameters:
duration0
- the first operand, a string in the format of an ISO durationduration1
- the second operand, a string in the format of an ISO duration- Returns:
- a string representation of the total duration, or "" if the input is invalid or the total is inexpressible
-
difference
public static java.lang.String difference(XPathContext context, java.lang.String dateLeftIn, java.lang.String dateRightIn)
The date:difference function returns the duration between the first date and the second date.If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration.
The two dates must both be right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes].
The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation).
The permitted formats are as follows, from most specific to least specific:
- xs:dateTime (CCYY-MM-DDThh:mm:ss)
- xs:date (CCYY-MM-DD)
- xs:gYearMonth (CCYY-MM)
- xs:gYear (CCYY)
If either of the arguments is not in one of these formats, date:difference returns the empty string ('').
The difference between the date/times is returned as a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes].
If the date/time string with the least specific format is in either xs:gYearMonth or xs:gYear format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero. (The format of the string will be PnYnM.) The number of months specified in the duration must be less than 12. Otherwise, the number of years and months in the duration string must be equal to zero. (The format of the string will be PnDTnHnMnS.) The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24.
- Parameters:
context
- the XPath dynamic contextdateLeftIn
- the first operand, a string in the format of an ISO dateTime, date, yearMonth, or yeardateRightIn
- the second operand, a string in the format of an ISO dateTime, date, yearMonth, or year- Returns:
- a string representation of the difference as an ISO duration, or "" if the input is invalid or the difference is inexpressible
-
duration
public static java.lang.String duration(double seconds)
The date:duration function returns a duration string representing the number of seconds specified by the argument string. If no argument is given, then the result of calling date:seconds without any arguments is used as a default argument. The duration is returned as a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. The number of years and months in the duration string must be equal to zero. (The format of the string will be PnDTnHnMnS.) The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24. If the argument is Infinity, -Infinity or NaN, then date:duration returns an empty string ('').- Parameters:
seconds
- the input number of seconds- Returns:
- the duration as a string in ISO format
-
seconds
public static double seconds(XPathContext context) throws XPathException
Return the number of seconds since 1 Jan 1970- Parameters:
context
- the XPath dynamic context- Returns:
- the number of seconds since 1 Jan 1970 (the "epoch" according to Java and Unix)
- Throws:
XPathException
- if the context does not allow a date/time to be established
-
seconds
public static double seconds(XPathContext context, java.lang.String datetimeIn)
The date:seconds function returns the number of seconds specified by the argument string. If no argument is given, then the current local date/time, as returned by date:date-time is used as a default argument.The argument string may be in one of the following formats:
- A right-truncated date/time string in one of the formats defined in
[XML Schema Part 2: Datatypes].
In these cases, the difference between the date/time string and 1970-01-01T00:00:00Z
is calculated as with date:difference and the result is converted to seconds with
date:seconds.
The legal formats are as follows:
- xs:dateTime (CCYY-MM-DDThh:mm:ss)
- xs:date (CCYY-MM-DD)
- xs:gYearMonth (CCYY-MM)
- xs:gYear (CCYY)
- A duration specified in days, hours, minutes and seconds in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. The number of years and months in the duration string must both be equal to zero: either P0Y0M120D or P120D are permitted, but P3M is not. If the argument to date:seconds is defined as a duration, the number returned is the result of converting the duration to seconds by assuming that 1 day = 24 hours, 1 hour = 60 minutes and 1 minute = 60 seconds. The permitted duration format is basically PnDTnHnMnS, although implementers should consult [XML Schema Part 2: Datatypes] and [ISO 8601] for details.
If the argument is not in any of these formats, date:seconds returns NaN.
- Parameters:
context
- the XPath dynamic contextdatetimeIn
- the input dateTime, date, yearMonth, or year as an ISO string- Returns:
- the number of seconds since 1 Jan 1970 (the "epoch" according to Java and Unix)
- A right-truncated date/time string in one of the formats defined in
[XML Schema Part 2: Datatypes].
In these cases, the difference between the date/time string and 1970-01-01T00:00:00Z
is calculated as with date:difference and the result is converted to seconds with
date:seconds.
The legal formats are as follows:
-
-