roll. Shifting date

^date.roll[year](shift)
^date.roll[month](shift)
^date.roll[day](shift)
^date.roll[TZ][new time zone]

This method increases/decreases values of fields
year, month, and day of objects of class date.

You can also get date/time stored in an object of class
date in another time zone by specifying system name of a new time zone. For the list of these names, please see your system documentation (search for: "Environment variable TZ").

Example of shifting a month
$today[^date::now[]]
^today.roll[month](-1)
$today.
month

In this example, we assign variable
$today the value of current day and then decrease the number of the current month by one. As a result, we get the value of the previous month.

Example of shifting time zone

@main[]
$now[^date::
now[]]
^show[]
^show[Moscow;MSK-3MSD]
^show[
Amsterdam;MET-1DST]
^show[
London;GMT0BST]
^show[
New York;EST5EDT]
^show[
Chicago;CST6CDT]
^show[
Denver;MST7MDT]
^show[
Los Angeles;PST8PDT]

@show[town;TZ]
^if(
def $town){
    $town
    ^now.roll[TZ;$TZ]
}{
    Server local time
}
<br />
$now.year/$now.month/$now.day, $now.hour hrs $now.minute mins<hr />


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 20.09.2007