Altova MapForce 2023 Basic Edition

xpath2 | durations, date and time functions

Home Prev Top Next

The duration, date and time functions from the xpath2 library enable you to adjust the time zone in date and time values, extract particular components from date, time, and duration values, and subtract date and time values.

 

Adjusting the time zone

To adjust the time zone in date and time values, the following functions are available:

 

adjust-date-to-timezone

adjust-date-to-timezone (with timezone argument)

adjust-dateTime-to-timezone

adjust-dateTime-to-timezone (with timezone argument)

adjust-time-to-timezone

adjust-time-to-timezone (with timezone argument)

 

Each of these related functions takes an xs:date, xs:time, or xs:dateTime value as the first argument and adjusts the input by adding, removing, or modifying the time zone component depending on the value of the second argument (if one is present).

 

The following situations are possible when the first argument contains no time zone (for example, the date 2020-01 or the time 14:00:00).

 

If the timezone argument is present, the result will contain the time zone specified in the second argument. The time zone in the second argument is added.

If the timezone argument is absent, the result will contain the implicit timezone, which is the system's time zone. The system's time zone is added.

If the timezone argument is empty, the result will contain no time zone.

 

The following situations are possible when the first argument contains a time zone (for example, the date 2020-01-01+01:00 or the time 14:00:00+01:00).

 

If the timezone argument is present, the result will contain the time zone specified in the second argument. The original time zone is replaced by the timezone in the second argument.

If the timezone argument is absent, the result will contain the implicit time zone, which is the system's time zone. The original time zone is replaced by the system's time zone.

If the timezone argument is empty, the result will contain no time zone.

 

Extracting components of dates and times

To extract numeric values such as hours, minutes, days, months, and so on from date and time values, the following functions are available:

 

day-from-date

day-from-dateTime

hours-from-dateTime

hours-from-time

minutes-from-dateTime

minutes-from-time

month-from-date

month-from-dateTime

seconds-from-dateTime

seconds-from-time

timezone-from-date

timezone-from-dateTime

timezone-from-time

year-from-date

year-from-dateTime

 

Each of these functions extracts a particular component from xs:date, xs:time, xs:dateTime, and xs:duration values. The result will be either xs:integer or xs:decimal.

 

Extracting components of durations

To extract time components from durations, the following functions are available:

 

days-from-duration

hours-from-duration

minutes-from-duration

months-from-duration

seconds-from-duration

years-from-duration

 

The duration must be specified either as xs:yearMonthDuration (for extracting years and months) or xs:dayTimeDuration (for extracting days, hours, minutes, and seconds). All functions returns a result of type xs:integer, with the exception of the seconds-from-duration function, which returns xs:decimal.

 

Subtracting date and time values

To subtract date and time values, the following functions are available:

 

subtract-dateTimes

subtract-dates

subtract-times

 

Each of the subtraction functions enables you to subtract one time value from another and return a duration value.

© 2017-2023 Altova GmbH