Date & Time Macros

The macros in the sample date_time_macros.cfg configuration file below can be used as shortcuts for specifying dates and times, also for other special date and time purposes.

///////////////////////////////////////////////////////////////////////////////
 
// date & time macros - date & time shortcuts
 
///////////////////////////////////////////////////////////////////////////////

secs_in_day     (60*60*24)
 
///////////////////////////////////////////////////////////////////////////////
 
sunday          ( #weekday() == 1 )
monday          ( #weekday() == 2 )
tuesday         ( #weekday() == 3 )
wednesday       ( #weekday() == 4 )
thursday        ( #weekday() == 5 )
friday          ( #weekday() == 6 )
saturday        ( #weekday() == 7 )
 
weekend         ( =saturday || =sunday )
weekday         ( ! =weekend )
 
///////////////////////////////////////////////////////////////////////////////
 
january         ( #month() ==  1 )
february        ( #month() ==  2 )
march           ( #month() ==  3 )
april           ( #month() ==  4 )
may             ( #month() ==  5 )
june            ( #month() ==  6 )
july            ( #month() ==  7 )
august          ( #month() ==  8 )
september       ( #month() ==  9 )
october         ( #month() == 10 )
november        ( #month() == 11 )
december        ( #month() == 12 )
 
///////////////////////////////////////////////////////////////////////////////

months          Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
 
///////////////////////////////////////////////////////////////////////////////
 
night                            ( #hour() <   6 )
morning         ( #hour() >=  6 && #hour() <  12 )
afternoon       ( #hour() >= 12 && #hour() <  18 )
evening         ( #hour() >= 18 )
 
///////////////////////////////////////////////////////////////////////////////

nowdst          // the current time, #now(), adjusted for Daylight Savings Time
                #now()
#ifdef dst
                       + 3600
#endifdef
 
///////////////////////////////////////////////////////////////////////////////

datenow         // the current date, as MM/DD/YYYY
#verbatim [date +%F]

monthnow
#verbatim [date +%B]

yymmnow
#verbatim [date +%y%m]
 
///////////////////////////////////////////////////////////////////////////////

set_datestamp   // set $datestamp = "991215", for example
                set $datestamp = $right($text(#year()),2) .
                                 $if(#month()<10, "0", "") .
                                 $text(#month()) . $if(#day()<10, "0", "") .
                                 $text(#day())
 
///////////////////////////////////////////////////////////////////////////////

set_hr(L)       // set the #hr, either the current hour, if no (L) is supplied,
                // or the hour in the given input line, as in a typical logfile
                // entry
                if "(L)" eq ""          // as with:  =set_hr()
                        set #hr = #hour()
                else                    // as with:  =set_hr($inlin)
                        if (L) =~ "(=months)[[:space:]]+[[:digit:]]+
                                            [[:space:]]+([[:digit:]]+):"
                                set #hr = $2
                        else
                                set #hr = #err()
                        endif
                endif
 
///////////////////////////////////////////////////////////////////////////////

Open Hand For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
date & time
macros