PIKT

Samples: Date & Time Macros

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


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 & 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 )

///////////////////////////////////////////////////////////////////////////////

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

///////////////////////////////////////////////////////////////////////////////

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

///////////////////////////////////////////////////////////////////////////////

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

Essential CVS
Essential CVS

Beginning SuSE Linux: From Novice To Professional
Beginning SuSE Linux: From Novice To Professional

Automating Unix and Linux Administration
Automating Unix and Linux Administration

The Linux Enterprise Cluster
The Linux Enterprise Cluster

Managing Linux Systems with Webmin
Managing Linux Systems with Webmin