#hour()
(NOTE: Some of the techniques shown or described on this page--marked in purple--require new features in the latest official PIKT 1.19.0 release (pikt-current.tar.gz) that are unavailable in any previous version.)
DESCRIPTION returns the current hour (0-23) or: returns the hour portion (0-23) of the given datevalue/timevalue
SYNOPSIS #hour() or: #hour(d) or: #hour(t)
ARGUMENTS none or: d - a datevalue, or datevalue expression or: t - a timevalue, or timevalue expression
EXAMPLES
# pikt +C 'output $text(#hour())' 14 # pikt +C 'output $text(#hour(#now()))' 14
night ( #hour() < 6 ) morning ( #hour() >= 6 && #hour() < 12 ) afternoon ( #hour() >= 12 && #hour() < 18 ) evening ( #hour() >= 18 )
once_daily(A) // set #hr = #hour()
if #hr < %hr
(A)
fi
bypass_day_rollover if ( #hour() == 23 ) || ( #hour() == 0 && #minute() < 30 ) quit fi
rule
if $alert() =~~ "hourly|critical"
if #hour() > 6 // only run midnight to 6 am
quit
fi
fi
rule // ignore scheduled reboots
if =reboot_period(#daynumber(), #hour())
next
fi
rule // make a history copy of all new scripts
if ! #defined(%fmt[$fil])
if =offhours(#hour())
doexec wait "=cp -p $fil $hstfil"
output log "(L)" "new script: $fil"
fi
next
fi
businessopen(H) // beginning of a normal business day (=weekday && ((H) >= 8 && (H) < 10)) checkpoint(LA) #ifdef debug output $chop($command("=uptime | =awk '{print \$10}'")) #endifdef #if dbserver if =businessopen(#hour()) if $level() !~~ "emerg" quit fi fi #endif set #la = #val($chop($command("=uptime | =awk '{print \$10}'"))) if #la >= (LA) output log "=logdir/Checkpoint.log" "quit $alarm(), load average $text(#la, 2)" quit fi
SEE ALSO #minute() #now() #second() #today() #datevalue() #timevalue() Numerical Functions String Functions