@@ -94,21 +94,22 @@ int main() {
9494 // OPTIONAL: set the 'TZ' env variable to the local POSIX timezone (in this case Europe/London,
9595 // to create your own see https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_431.html)
9696 setenv ("TZ" , "BST0GMT,M3.5.0/1,M10.5.0/2" , 1 );
97- // If you set 'TZ' then functions like ctime(), localtime() and their variants will automatically
98- // give results converted to the local timezone instead of UTC (see below).
97+ // If the environment contains a valid 'TZ' definition then functions like ctime(), localtime()
98+ // and their variants automatically give results converted to the local timezone instead of UTC
99+ // (see below).
99100
100101 while (true) {
101102
102103 if (aon_timer_is_initialised ) {
103104
104- // read the current time as UTC seconds and ms since the epoch
105+ // safely read the current time as UTC seconds and ms since the epoch
105106 get_time_utc (& ts );
106107
107108 // if you just want a string representation of the current time and you're not interested
108109 // in the individual date/time fields, then here you can simply call:
109110 // printf("%s", ctime(&(ts.tv_sec)));
110- // The string produced is the same as `asctime()` as used below. Note that if you set
111- // 'TZ' then the output will be in local time, otherwise UTC.
111+ // The string produced is the same as `asctime()` (see below) . Note that if you set 'TZ'
112+ // then the output will be in local time, otherwise UTC.
112113
113114 // you can unpack the raw UTC seconds count into individual date/time fields like this.
114115 // Again, if you set 'TZ' then the values will be in local time, otherwise UTC. Note
@@ -119,6 +120,8 @@ int main() {
119120
120121 // display individual date/time fields in human readable form
121122 printf ("%s: %s" , tm .tm_isdst ? "BST" : "GMT" , asctime (& tm ));
123+ // asctime(), ctime() and their variants produce strings of the form "Mon Oct 27 22:06:08 2025\n"
124+ // - note the trailing '\n'.
122125
123126 } else {
124127 puts ("system time not yet initialised" );
0 commit comments