Index: src/libcfa/time
===================================================================
--- src/libcfa/time	(revision 6ecc079f66df192d98cedfc66c3766f9fc5704a8)
+++ src/libcfa/time	(revision b10affdcb702e2f50d20fa65715ce6473d2bebb4)
@@ -1,15 +1,15 @@
 // 
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
 //
 // The contents of this file are covered under the licence agreement in the
 // file "LICENCE" distributed with Cforall.
 // 
-// calendar -- 
+// time -- 
 // 
 // Author           : Peter A. Buhr
 // Created On       : Wed Mar 14 23:18:57 2018
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Mar 22 17:11:19 2018
-// Update Count     : 495
+// Last Modified On : Tue Mar 27 16:37:37 2018
+// Update Count     : 564
 // 
 
@@ -19,37 +19,40 @@
 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0355r5.html#refcc
 
-#include <time.h>
+#include <time.h>										// timespec
 extern "C" {
-#include <sys/time.h>
-int snprintf( char * buf, size_t size, const char * fmt, ... );
+#include <sys/time.h>									// timeval
 }
-#include <fstream>
-
-enum {
-	CLOCKGRAN = 15_000_000L,							// ALWAYS in nanoseconds, MUST BE less than 1 second
-	TIMEGRAN = 1_000_000_000L							// nanosecond granularity, except for timeval
-};
-
-
-#if defined( REALTIME_POSIX )
-#define tv_XSEC tv_nsec
-#else
-#define tv_XSEC tv_usec
-#endif
-
-
-#if defined( __linux__ )
-// fake a few things
-#define	CLOCK_REALTIME	0								// real (clock on the wall) time
-#endif
-
-// conversions for existing time types
+#include <iostream>										// istype/ostype
+
+enum { TIMEGRAN = 1_000_000_000L };						// nanosecond granularity, except for timeval
+
+
+//######################### timeval #########################
+
 static inline void ?{}( timeval & t ) {}
 static inline void ?{}( timeval & t, time_t sec ) { t.tv_sec = sec; t.tv_usec = 0; }
 static inline void ?{}( timeval & t, time_t sec, suseconds_t usec ) { t.tv_sec = sec; t.tv_usec = usec; }
+static inline void ?{}( timeval & t, zero_t ) { t.tv_sec = 0; t.tv_usec = 0; }
+static inline timeval ?=?( timeval & t, zero_t ) { return t{ 0 }; }
+static inline timeval ?+?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_usec + rhs.tv_usec }; }
+static inline timeval ?-?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_usec - rhs.tv_usec }; }
+static inline _Bool ?==?( timeval lhs, timeval rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_usec == rhs.tv_usec; }
+static inline _Bool ?!=?( timeval lhs, timeval rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_usec != rhs.tv_usec; }
+
+
+//######################### timespec #########################
 
 static inline void ?{}( timespec & t ) {}
 static inline void ?{}( timespec & t, time_t sec ) { t.tv_sec = sec; t.tv_nsec = 0; }
 static inline void ?{}( timespec & t, time_t sec, __syscall_slong_t nsec ) { t.tv_sec = sec; t.tv_nsec = nsec; }
+static inline void ?{}( timespec & t, zero_t ) { t.tv_sec = 0; t.tv_nsec = 0; }
+static inline timespec ?=?( timespec & t, zero_t ) { return t{ 0 }; }
+static inline timespec ?+?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_nsec + rhs.tv_nsec }; }
+static inline timespec ?-?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_nsec - rhs.tv_nsec }; }
+static inline _Bool ?==?( timespec lhs, timespec rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_nsec == rhs.tv_nsec; }
+static inline _Bool ?!=?( timespec lhs, timespec rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_nsec != rhs.tv_nsec; }
+
+
+//######################### C time #########################
 
 static inline char * ctime( time_t tp ) { char * buf = ctime( &tp ); buf[24] = '\0'; return buf; }
@@ -60,5 +63,4 @@
 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }
 
-
 //######################### Duration #########################
 
@@ -69,4 +71,6 @@
 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }
 static inline void ?{}( Duration & dur, Duration d ) with( dur ) { tv = d.tv; }
+static inline void ?{}( Duration & dur, zero_t ) with( dur ) { tv = 0; }
+static inline Duration ?=?( Duration & dur, zero_t ) { return dur{ 0 }; }
 
 static inline void ?{}( Duration & dur, timeval t ) with( dur ) {
@@ -88,8 +92,74 @@
 } // ?=? timespec
 
+static inline int64_t nsecs( Duration dur ) with( dur ) { return tv; }
+
+static inline Duration +?( Duration rhs ) with( rhs ) {	return (Duration)@{ +tv }; }
+static inline Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
+static inline Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
+
+static inline Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
+static inline Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
+static inline Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
+
+static inline Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
+static inline Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
+static inline Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
+
+static inline Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
+static inline int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
+static inline Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
+
+static inline Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tv % rhs.tv }; }
+
+static inline _Bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }
+static inline _Bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }
+static inline _Bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv <  rhs.tv; }
+static inline _Bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }
+static inline _Bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv >  rhs.tv; }
+static inline _Bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }
+
+static inline _Bool ?==?( Duration lhs, zero_t ) { return lhs.tv == 0; }
+static inline _Bool ?!=?( Duration lhs, zero_t ) { return lhs.tv != 0; }
+static inline _Bool ?<? ( Duration lhs, zero_t ) { return lhs.tv <  0; }
+static inline _Bool ?<=?( Duration lhs, zero_t ) { return lhs.tv <= 0; }
+static inline _Bool ?>? ( Duration lhs, zero_t ) { return lhs.tv >  0; }
+static inline _Bool ?>=?( Duration lhs, zero_t ) { return lhs.tv >= 0; }
+
+static inline Duration abs( Duration lhs ) { return lhs.tv >= 0 ? lhs : -lhs; }
+
+forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
+
+static inline Duration ?`ns( int64_t nsec  ) { return (Duration)@{ nsec }; }
+static inline Duration ?`us( int64_t usec  ) { return (Duration)@{ usec * (TIMEGRAN / 1_000_000L) }; }
+static inline Duration ?`ms( int64_t msec  ) { return (Duration)@{ msec * (TIMEGRAN / 1_000L) }; }
+static inline Duration ?`s ( int64_t sec   ) { return (Duration)@{ sec * TIMEGRAN }; }
+static inline Duration ?`s ( double  sec   ) { return (Duration)@{ sec * TIMEGRAN }; }
+static inline Duration ?`m ( int64_t min   ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
+static inline Duration ?`m ( double  min   ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
+static inline Duration ?`h ( int64_t hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
+static inline Duration ?`h ( double  hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
+static inline Duration ?`d ( int64_t days  ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
+static inline Duration ?`d ( double  days  ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
+static inline Duration ?`w ( int64_t weeks ) { return (Duration)@{ weeks * (7L * 24L * 3600L * TIMEGRAN) }; }
+static inline Duration ?`f ( int64_t fortnight ) { return (Duration)@{ fortnight * (14L * 24L * 3600L * TIMEGRAN) }; }
+
+static inline int64_t ?`ns ( Duration dur ) { return dur.tv; }
+static inline int64_t ?`us ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000L); }
+static inline int64_t ?`ms ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000L); }
+static inline int64_t ?`s  ( Duration dur ) { return dur.tv / TIMEGRAN; }
+static inline int64_t ?`m  ( Duration dur ) { return dur.tv / (60L * TIMEGRAN); }
+static inline int64_t ?`h  ( Duration dur ) { return dur.tv / (3600L * TIMEGRAN); }
+static inline int64_t ?`d  ( Duration dur ) { return dur.tv / (24L * 3600L * TIMEGRAN); }
+static inline int64_t ?`w  ( Duration dur ) { return dur.tv / (7L * 24L * 3600L * TIMEGRAN); }
+static inline int64_t ?`f  ( Duration dur ) { return dur.tv / (14L * 24L * 3600L * TIMEGRAN); }
+
+//------------------------- timeval (cont) -------------------------
+
 static inline void ?{}( timeval & t, Duration dur ) with( dur ) {
 	t.tv_sec = tv / TIMEGRAN;							// seconds
-	t.tv_usec = tv % TIMEGRAN / ( TIMEGRAN / 1000000L ); // microseconds
+	t.tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000L); // microseconds
 } // ?{}
+
+//------------------------- timespec (cont) -------------------------
 
 static inline void ?{}( timespec & t, Duration dur ) with( dur ) {
@@ -98,69 +168,4 @@
 } // Timespec
 
-static inline int64_t nsecs( Duration dur ) with( dur ) { return tv; }
-
-static inline Duration +?( Duration rhs ) with( rhs ) {	return (Duration)@{ +tv }; }
-static inline Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
-static inline Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
-
-static inline Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
-static inline Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
-static inline Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
-
-static inline Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
-static inline Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
-static inline Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
-
-static inline Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
-static inline int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
-static inline Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
-
-static inline Duration ?%?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv % rhs }; }
-static inline int64_t ?%?( int64_t lhs, Duration rhs ) { return lhs % (rhs.tv / TIMEGRAN); }
-static inline int64_t ?%?( Duration lhs, Duration rhs ) { return lhs.tv % rhs.tv; }
-
-static inline _Bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }
-static inline _Bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }
-static inline _Bool ?<?( Duration lhs, Duration rhs ) { return lhs.tv < rhs.tv; }
-static inline _Bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }
-static inline _Bool ?>?( Duration lhs, Duration rhs ) { return lhs.tv > rhs.tv; }
-static inline _Bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }
-
-static inline Duration abs( Duration lhs ) {
-	return lhs.tv >= 0 ? lhs : -lhs;
-} // abs
-
-static inline forall( dtype ostype | ostream( ostype ) )
-ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
-	os | tv / TIMEGRAN;
-	char buf[16];
-	snprintf( buf, 16, "%09ld", ((tv < 0 ? -tv : tv) % TIMEGRAN) );
-	int i;
-	for ( i = 8; i >= 0 && buf[i] == '0' ; i -= 1 );	// find least significant digit
-	if ( i != -1 ) { buf[i + 1] = '\0';	os | '.' | buf; }
-	return os;
-}
-
-static inline Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; }
-static inline Duration ?`us( int64_t usec ) { return (Duration)@{ usec * (TIMEGRAN / 1_000l) }; }
-static inline Duration ?`ms( int64_t msec ) { return (Duration)@{ msec * (TIMEGRAN / 1_000_000l) }; }
-static inline Duration ?`s ( int64_t sec ) { return (Duration)@{ sec * TIMEGRAN }; }
-static inline Duration ?`s ( double  sec ) { return (Duration)@{ sec * TIMEGRAN }; }
-static inline Duration ?`m ( int64_t min ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
-static inline Duration ?`m ( double  min ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
-static inline Duration ?`h ( int64_t hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
-static inline Duration ?`h ( double  hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
-static inline Duration ?`d ( int64_t days ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
-static inline Duration ?`d ( double  days ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
-static inline Duration ?`w ( int64_t weeks ) { return (Duration)@{ weeks * (7L * 24L * 3600L * TIMEGRAN) }; }
-static inline Duration ?`f ( int64_t fortnight ) { return (Duration)@{ fortnight * (14L * 24L * 3600L * TIMEGRAN) }; }
-
-static inline int64_t ?`s ( Duration dur ) { return dur.tv / TIMEGRAN; }
-static inline int64_t ?`m ( Duration dur ) { return dur.tv / (60L * TIMEGRAN); }
-static inline int64_t ?`h ( Duration dur ) { return dur.tv / (3600L * TIMEGRAN); }
-static inline int64_t ?`d ( Duration dur ) { return dur.tv / (24L * 3600L * TIMEGRAN); }
-static inline int64_t ?`w ( Duration dur ) { return dur.tv / (7L * 24L * 3600L * TIMEGRAN); }
-static inline int64_t ?`f ( Duration dur ) { return dur.tv / (14L * 24L * 3600L * TIMEGRAN); }
-
 
 //######################### Time #########################
@@ -171,33 +176,5 @@
 };
 
-#ifdef __CFA_DEBUG__
-#define CreateFmt "Attempt to create Time( year=%d, month=%d, day=%d, hour=%d, min=%d, sec=%d, nsec=%d ), " \
-	"which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038."
-#endif // __CFA_DEBUG__
-
-void mktime( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
-	tm tm;
-
-//	tzset();											// initialize time global variables
-	tm.tm_isdst = -1;									// let mktime determine if alternate timezone is in effect
-	tm.tm_year = year - 1900;							// mktime uses 1900 as its starting point
-	tm.tm_mon = month - 1;
-	tm.tm_mday = day;									// mktime uses range 1-31
-	tm.tm_hour = hour;
-	tm.tm_min = min;
-	tm.tm_sec = sec;
-	time_t epochsec = mktime( &tm );
-#ifdef __CFA_DEBUG__
-	if ( epochsec == (time_t)-1 ) {
-		abort( CreateFmt, year, month, day, hour, min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-	tv = (int64_t)(epochsec) * TIMEGRAN + nsec;			// convert to nanoseconds
-#ifdef __CFA_DEBUG__
-	if ( tv > 2147483647LL * TIMEGRAN ) {				// between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
-		abort( CreateFmt, year, month, day, hour, min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-} // mktime
+void mktime( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec );
 
 static inline void ?{}( Time & t ) with( t ) {
@@ -205,43 +182,30 @@
 } // Time
 
-// These two constructors must not call mktime because it calls malloc. The malloc calls lead to recursion problems
-// because Time values are created from the sigalrm handler in composing the next context switch event.
-
-static inline void ?{}( Time & t, int sec ) with( t ) {
-#ifdef __CFA_DEBUG__
-	if ( tv < 0 || tv > 2147483647LL ) {				// between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
-	    abort( CreateFmt, 1970, 0, 0, 0, 0, sec, 0 );
-	} // if
-#endif // __CFA_DEBUG__
-	tv = (int64_t)sec * TIMEGRAN;
-} // Time
-
-static inline void ?{}( Time & t, int sec, int nsec ) with( t ) {
-#ifdef __U_DEBUG__
-	if ( tv < 0 || tv > 2147483647LL || nsec < 0 ) {	// between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
-	    abort( CreateFmt, 1970, 0, 0, 0, 0, sec, nsec );
-	} // if
-#endif // __U_DEBUG__
-	tv = (int64_t)sec * TIMEGRAN + nsec;
-} // Time
-
-static inline void ?{}( Time & time, int min, int sec, long int nsec ) {
-	mktime( time, 1970, 1, 1, 0, min, sec, nsec );
-} // Time
-
-static inline void ?{}( Time & time, int hour, int min, int sec, long int nsec ) {
-	mktime( time, 1970, 1, 1, hour, min, sec, nsec );
-} // Time
-
-static inline void ?{}( Time & time, int day, int hour, int min, int sec, long int nsec ) {
-	mktime( time, 1970, 1, day, hour, min, sec, nsec );
-} // Time
-
-static inline void ?{}( Time & time, int month, int day, int hour, int min, int sec, long int nsec ) {
-	mktime( time, 1970, month, day, hour, min, sec, nsec );
-} // Time
-
-static inline void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, long int nsec ) {
+static inline void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) {
 	mktime( time, year, month, day, hour, min, sec, nsec );
+} // Time
+
+static inline void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec ) {
+	mktime( time, year, month, day, hour, min, sec, 0 );
+} // Time
+
+static inline void ?{}( Time & time, int year, int month, int day, int hour, int min ) {
+	mktime( time, year, month, day, hour, min, 0, 0 );
+} // Time
+
+static inline void ?{}( Time & time, int year, int month, int day, int hour ) {
+	mktime( time, year, month, day, hour, 0, 0, 0 );
+} // Time
+
+static inline void ?{}( Time & time, int year, int month, int day ) {
+	mktime( time, year, month, day, 0, 0, 0, 0 );
+} // Time
+
+static inline void ?{}( Time & time, int year, int month ) {
+	mktime( time, year, month, 0, 0, 0, 0, 0 );
+} // Time
+
+static inline void ?{}( Time & time, int year ) {
+	mktime( time, year, 0, 0, 0, 0, 0, 0 );
 } // Time
 
@@ -254,6 +218,9 @@
 } // Time
 
+static inline void ?{}( Time & t, zero_t ) { t.tv = 0; }
+static inline Time ?=?( Time & t, zero_t ) { return t{ 0 }; }
+
 static inline Time ?=?( Time & time, timeval t ) with( time ) {
-	tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000;
+	tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000L);
 	return time;
 } // ?=?
@@ -273,6 +240,4 @@
 	t.tv_nsec = tv % TIMEGRAN;							// nanoseconds
 } // ?{}
-
-static inline int64_t nsec( Time time ) with( time ) { return tv; }
 
 static inline Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
@@ -290,51 +255,23 @@
 static inline _Bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
 
-static inline char * yymmd( Time time, char * buf ) with( time ) {
-	tm tm;
-	time_t s = tv / TIMEGRAN;
-	gmtime_r( &s, &tm );
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_year % 99, tm.tm_mon, tm.tm_mday );
-	return buf;
-} // yymmd
-
-static inline char * mmyyd( Time time, char * buf ) with( time ) {
-	tm tm;
-	time_t s = tv / TIMEGRAN;
-	gmtime_r( &s, &tm );
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mon, tm.tm_year % 99, tm.tm_mday );
-	return buf;
-} // yymmd
-
-static inline char * dmmyy( Time time, char * buf ) with( time ) {
-	tm tm;
-	time_t s = tv / TIMEGRAN;
-	gmtime_r( &s, &tm );
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mday, tm.tm_mon, tm.tm_year % 99 );
-	return buf;
-} // yymmd
-
-static inline forall( dtype ostype | ostream( ostype ) )
-ostype & ?|?( ostype & os, Time time ) with( time ) {
-	char buf[32];										// at least 26
-	time_t s = tv / TIMEGRAN;
-	tm tm;
-	gmtime_r( &s, &tm );								// ctime_r adjusts for timezone
-	asctime_r( &tm, (char *)&buf );
-	buf[24] = '\0';										// remove trailing '\n'
-	long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;
-	if ( ns == 0 ) {
-		os | buf;
-	} else {
-		buf[19] = '\0';
-		os | buf;
-		char buf2[16];
-		snprintf( buf2, 16, "%09ld", ns );
-		int i;
-		for ( i = 8; i >= 0 && buf2[i] == '0' ; i -= 1 ); // find least significant digit
-		if ( i != -1 ) { buf2[i + 1] = '\0'; os | '.' | buf2; }
-		os | ' ' | &buf[20];
-	} // if
-	return os;
-} // ?|?
+char * yy_mm_dd( Time time, char * buf );
+static inline char * ?`ymd( Time time, char * buf ) {
+	return yy_mm_dd( time, buf );
+} // ymd
+
+char * mm_dd_yy( Time time, char * buf );
+static inline char * ?`mdy( Time time, char * buf ) {
+	return mm_dd_yy( time, buf );
+} // mdy
+
+char * dd_mm_yy( Time time, char * buf );
+static inline char * ?`dmy( Time time, char * buf ) {
+	return dd_mm_yy( time, buf );;
+} // dmy
+
+size_t strftime( char * buf, size_t size, const char * fmt, Time time );
+
+forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
+
 
 //######################### Clock #########################
@@ -346,9 +283,9 @@
 };
 
-void resetClock( Clock & clk ) with( clk ) {
-	clocktype = CLOCK_REALTIME;
+static inline void resetClock( Clock & clk ) with( clk ) {
+	clocktype = CLOCK_REALTIME_COARSE;
 } // Clock::resetClock
 
-void resetClock( Clock & clk, Duration adj ) with( clk ) {
+static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {
 	clocktype = -1;
 	Duration tz = (timeval){ timezone, 0 };
@@ -356,19 +293,19 @@
 } // resetClock
 
-void ?{}( Clock & clk ) {
+static inline void ?{}( Clock & clk ) {
 	resetClock( clk );
 } // Clock
 
-void ?{}( Clock & clk, Duration adj ) {
+static inline void ?{}( Clock & clk, Duration adj ) {
 	resetClock( clk, adj );
 } // Clock
 
-Duration getRes() {
+static inline Duration getRes() {
 	struct timespec res;
-	clock_getres( CLOCK_REALTIME, &res );
+	clock_getres( CLOCK_REALTIME_COARSE, &res );
 	return (Duration){ res };
 } // getRes
 
-Time getTime() {
+static inline Time getTimeNsec() {						// with nanoseconds
 	timespec curr;
 	clock_gettime( CLOCK_REALTIME_COARSE, &curr );
@@ -376,17 +313,24 @@
 } // getTime
 
-Time getTime( Clock & clk ) with( clk ) {
+static inline Time getTime() {							// without nanoseconds
+	timespec curr;
+	clock_gettime( CLOCK_REALTIME_COARSE, &curr );
+	curr.tv_nsec = 0;
+	return (Time){ curr };
+} // getTime
+
+static inline Time getTime( Clock & clk ) with( clk ) {
 	return getTime() + offset;
 } // getTime
 
-Time ?()( Clock & clk ) with( clk ) {					// alternative syntax
+static inline Time ?()( Clock & clk ) with( clk ) {		// alternative syntax
 	return getTime() + offset;
 } // getTime
 
-timeval getTime( Clock & clk ) {
+static inline timeval getTime( Clock & clk ) {
 	return (timeval){ clk() };
 } // getTime
 
-tm getTime( Clock & clk ) with( clk ) {
+static inline tm getTime( Clock & clk ) with( clk ) {
 	tm ret;
 	localtime_r( getTime( clk ).tv_sec, &ret );
@@ -398,3 +342,2 @@
 // tab-width: 4 //
 // End: //
-
