4Suite™ API Documentation

# ► Module Ft.Xml.Xslt.Exslt.DateTime

Implementation of EXSLT Dates and Times module

    Copyright 2003 Fourthought, Inc. (USA).
    Detailed license and copyright information: http://4suite.org/COPYRIGHT
    Project home, documentation, distributions: http://4suite.org/

Classes: DateFormatElement |  |  |  | Functions: Add, AddDuration, Date, DateTime, DayAbbreviation, DayInMonth, DayInWeek, DayInYear, DayName, DayOfWeekInMonth, Difference, Duration, FormatDate, HourInDay, LeapYear, MinuteInHour, MonthAbbreviation, MonthInYear, MonthName, ParseDate, SecondInMinute, Seconds, SecondsFromDate, SecondsFromDuration, Sum, Time, WeekInMonth, WeekInYear, Year |  |  |  | Globals: EXSL_DATE_TIME_NS, ExtElements, ExtFunctions, ExtNamespaces, ISO_8601_DATE, ISO_8601_DATETIME, ISO_8601_TIME, durationRE

## Classes

class DateFormatElement(Ft.Xml.Xslt.StylesheetTree.XsltElement)

  ### Methods inherited from class Ft.Xml.Xslt.StylesheetTree.XsltElement

  __init__, __str__, appendChild, expandQName, insertChild, instantiate, parseAVT, parseExpression, parsePattern, processChildren, splitQName

  ### Methods inherited from class Ft.Xml.Xslt.StylesheetTree.XsltNode

  idle, isLastChild, isPseudoNode, pprint, prime, setup

  ### Members inherited from class Ft.Xml.Xslt.StylesheetTree.XsltElement

  category, content, legalAttrs, validator

  ### Members inherited from class Ft.Xml.Xslt.StylesheetTree.XsltNode

  attributes, baseUri, children, columnNumber, doesIdle, doesPrime, doesSetup, expandedName, importIndex, lineNumber, nodeName, parent, root

## Functions

Add(context, dateTime, duration)
  The date:add function returns the result of adding a duration to a dateTime.
AddDuration(context, duration1, duration2)
Date(context, dateTime=None)
  The date:date function returns the date portion of the dateTime argument if present, or of the current local date/time. The argument can be given in xs:dateTime or xs:date format.

      Non-conformance issues: The dateTime argument must be given in
      ISO 8601 date/time or date format, so an xs:date format with a
      time zone is not supported. Also, EXSLT requires that the result
      must include a time zone unless there was an argument given and
      it did not have a time zone. If a date/time argument is given,
      this implementation returns the date with no time zone info.

DateTime(context)
  The date:date-time function returns the current local date/time as an ISO 8601 formatted date/time string, with a time zone.
DayAbbreviation(context, dateTime=None)
  The date:day-abbreviation function returns the English abbreviation for the day name of a given date.
DayInMonth(context, dateTime=None)
  The date:day-in-month function returns the numerical date, i.e. 27 for the 27th of March.
DayInWeek(context, dateTime=None)
  The date:day-in-week function returns a number representing the weekday of a given date. Sunday is 1, Saturday is 7.
DayInYear(context, dateTime=None)
  The date:day-in-year function returns a number representing the position of a date in the year.
DayName(context, dateTime=None)
  The date:day-name function returns the full English day name of a given date.
DayOfWeekInMonth(context, dateTime=None)
  The date:day-of-week-in-month function returns the day-of-the-week in a month of a date as a number (e.g. 3 for the 3rd Tuesday in May).
Difference(context, dateTime1, dateTime2)
  The date:difference function returns the difference between dt1 and dt2 as a duration in string form.

      According to the spec (http://exslt.org/date/functions/difference/index.html)

      "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."

      This method does not account for leap seconds, so you
      should not expect precise results over long time spans.

Duration(context, seconds)
FormatDate(context, dateTime, pattern)
HourInDay(context, dateTime=None)
  The date:hour-in-date function returns the hour portion of a date- time string as an integer.
LeapYear(context, dateTime=None)
  The date:leap-year function returns true if the year argument (defaults to current year) is a leap year, false otherwise.
MinuteInHour(context, dateTime=None)
  The date:minute-in-hour function returns the minute portion of a date-time string as an integer.
MonthAbbreviation(context, dateTime=None)
  The date:month-abbreviation function returns the abbreviation of the month of a date.
MonthInYear(context, dateTime=None)
  The date:month-in-year function returns the month portion of the dateTime argument (defaults to current year) as an integer.
MonthName(context, dateTime=None)
  The date:month-name function returns the full English name of the month portion of a date.
ParseDate(context, dateString, pattern)
SecondInMinute(context, dateTime=None)
  The date:second-in-minute function returns the seconds portion of a date-time string as an integer.
Seconds(context, dateOrDuration)
SecondsFromDate(context, date)
SecondsFromDuration(duration)
Sum(context, nodeset)
Time(context, dateTime=None)
  The date:time function returns the time portion of the dateTime argument if present, or of the current local date/time. The argument can be given in xs:dateTime or xs:time format.

      Non-conformance issue: EXSLT requires that the result must include
      a time zone unless there was an argument given and it did not have
      a time zone. If an argument is given, this implementation returns
      the result with time zone info, always.

WeekInMonth(context, dateTime=None)
WeekInYear(context, dateTime=None)
  The date:week-in-year function returns a number representing the week of the year a date is in.
Year(context, dateTime=None)
  The date:year function returns the year portion of the dateTime supplied, or of the current year, as an integer.

## Globals

EXSL_DATE_TIME_NS = 'http://exslt.org/dates-and-times'
ExtElements = {}
ExtFunctions = {('http://exslt.org/dates-and-times', 'add'): <function Add>, ('http://exslt.org/dates-and-times', 'date'): <function Date>, ('http://exslt.org/dates-and-times', 'date-time'): <function DateTime>, ('http://exslt.org/dates-and-times', 'day-abbreviation'): <function DayAbbreviation>, ('http://exslt.org/dates-and-times', 'day-in-month'): <function DayInMonth>, ('http://exslt.org/dates-and-times', 'day-in-week'): <function DayInWeek>, ('http://exslt.org/dates-and-times', 'day-in-year'): <function DayInYear>, ('http://exslt.org/dates-and-times', 'day-name'): <function DayName>, ('http://exslt.org/dates-and-times', 'day-of-week-in-month'): <function DayOfWeekInMonth>, ('http://exslt.org/dates-and-times', 'difference'): <function Difference>, ...}
ExtNamespaces = {'http://exslt.org/dates-and-times': 'date'}
ISO_8601_DATE = '%Y-%m-%d'
ISO_8601_DATETIME = '%Y-%m-%dT%H:%M:%S'
ISO_8601_TIME = '%H:%M:%S'
durationRE = <_sre.SRE_Pattern object>
  Compiled regular expression objects