Time/CPU Cycles

Intel/AMD have an inst that returns the num of CPU cycles since boot. This is not a steady, calibrated real time value. TempleOS measures it and you can convert with cnts.time_stamp_freq, a value continuously calibrated from other cnts. Busy Funct Loosely timed. CCntsGlbls Class class CCntsGlbls CPURep Funct Report number of cores and clock freq. GetTSC Funct Get time stamp counter. PortNop Funct Innoculous (reads IRQ Mask) which should take fixed time cnts GlbVar CCntsGlbls cnts={1,0,2676302000,2676302,2676302000,0,0,0,FALSE};

Time/Date

Dates are 32-bit signed ints representing the number of days since the birth of Christ. Negative values represent B.C.E. dates. DayOfWeek Funct Day of week, given 32-bit day since AD 0. FirstDayOfMon Funct First day of month, given 32-bit day since AD 0. FirstDayOfYear Funct First day of year, given 32-bit day since AD 0. LastDayOfMon Funct Last day of month, given 32-bit day since AD 0. LastDayOfYear Funct Last day of year, given 32-bit day since AD 0. YearStartDate Funct 32-bit day since AD 0, given year number. mon_start_days1 GlbVar U16 mon_start_days1[12]={ mon_start_days2 GlbVar U16 mon_start_days2[12]={

Time/Date/CDate

TempleOS uses a 64-bit value, CDate, for date/time. The upper 32-bits are the days since Christ. The lower 32-bits store time of day divided by 4 billion which works out to 49710ths of a second. You can subtract two CDate's to get a time span. Use CDATE_FREQ to convert. Date2Struct Funct Cvt CDate to CDateStruct. Now Funct Current datetime. Str2Date Funct "*+nnnn", "*-nnnn", "mm/dd", "mm/dd/yy" Struct2Date Funct Cvt CDateStruct to CDate. local_time_offset GlbVar CDate local_time_offset;

Time/HPET

The HPET, high precision event timer, is read with HPET() and has a frequency of cnts.HPET_freq. A typical freq value is 14.3 Mhz It might not be available on all systems. CCntsGlbls Class class CCntsGlbls HPET Funct Get high precision event timer. cnts GlbVar CCntsGlbls cnts={1,0,2676302000,2676302,2676302000,0,0,0,FALSE};

Time/Jiffies

One jiffy is one time slice. cnts.jiffies returns time slices since boot. SysTimerRead reads the timer ticks since boot. It's not as fast as GetTSC. Use JIFFY_FREQ to convert cnts.jiffies. Use SYS_TIMER_FREQ to convert SysTimerRead. CCntsGlbls Class class CCntsGlbls Sleep Funct Not for power-saving. It is to make a program pause without hogging the CPU. SleepUntil Funct Not for power-saving. It is to make a program pause without hogging the CPU. SysTimerRead Funct System timer count with overflow already handled. cnts GlbVar CCntsGlbls cnts={1,0,2676302000,2676302,2676302000,0,0,0,FALSE};

Time/Seconds

Beat Funct Time in music beats. Blink Funct Return TRUE, then FALSE, then TRUE at given frequency. tM Funct Time in seconds synced to music subsystem. tS Funct Time since boot in seconds as a float.