Tinderbox v9 Icon

Date-time operators

Date accessors and manipulator operators are available for rules and actions:

The action code method to create a date string is to call the various date-related operators.

Date examples:

date(2004,7,23,16,45) …is 23 July 2004 16:45 

If $Date is July 4, 2009 then

day($Date) …is 4

If $Date is July 4,2009, then

$Date=day($Date,5) 

will change $Date to July 5, 2009.

If $Date is July 4, 2009 then

month($Date) …is 7

If $Date is July 4,2009, then

$Date=month($Date,5) 

will change $Date to May 4, 2009.

Note that using format() or .format() with Date or Interval data generates a String. Interval data is also expressed as a String. so if needing a duration in days or or mitures, consider the suite of difference measuring operators: years(), months(), weeks(), days(), hours(), minutes(), seconds(). Each of these takes two Date objects and returns the difference in the type of unit in the operator name. So hours() gives the Number of hours. The number is rounded down to give the count of whole hours, days—i.e. the calling time measure).

To get a similar unit-based measure of an Interval, use date("now") for the Date inputs but add the interval to one of them. the difference in the dates is now the interval and this can be tested with the above method. If $MyInterval is "-05:30" and $MyDate is "24/10/2022 12:00:00" (midday on 24 October 2022):

$MyDate = $MyDate + $MyInterval; 

results in $MyDate being 24/10/2022 11:54:30.

$MyNumberOfMinutes = minutes($MyDate,$MyDate+$MyInterval); 

By accepting negative intervals the same action code can deal with positive and negative durations. A more generalised approach to the last:

$MyNumberOfMinutes = minutes(date("now"),date("now")+$MyInterval); 

Here minutes are used but the method could test days, hours or seconds (not bigger units as Interval data us usually a few days at biggest and generally less than a whole day).