OpenWGA 7.7 - TMLScript reference


Object:

Date

Description Object representing date and time information in TMLScript.

This is not the standard JavaScript Date object, which is available in TMLScript but should not used. Instead this is the java.util.Date object known from Java. It preferred over the JavaScript object because there is no automatic conversion between the native JavaScript date and the Java date in TMLScript, which is neccessary to use dates with TMLScript and WGAPI methods.

This date object describes a special point in time, but has no dependency to any special calendar/time system. Therefor it cannot be used directly to read or write special date fields like month, year, hour etc. which are specific to a special calendar system.

You can use the method WGA.parseDate() to parse a calendar specific string into a date object and the function WGA.format() to again get a human readable, calendar specific date/time representation from it or single fields of it.

The method WGA.createDate() can be used to create a date object containing the time that the object was created.

You can use the method WGA.createCalendar() and the created calendar object to read the date/time information from a date object and let it be interpreted as a georgian calendar date. Then you can read specific fields like month, year, hour etc. or even modify them.
Retrieval WGA.createDate()
WGA.parseDate()
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
    portletevent
Properties and methods
Name Purpose
after(date) Tests if the current date is after the parameter date
before(date) Tests if the current date is before the parameter date
time Returns the stored timepoint as number
Examples The following example creates a date object carrying the current time and stores it as item on the users personalisation profile:

var currentTime = WGA.createDate();
profile.setItemValue("lasttime", currentTime);
profile.save();