Changeset 030653a
- Timestamp:
- Jun 18, 2020, 6:58:33 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 91e52be
- Parents:
- c1ee231
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/time.hfa
rc1ee231 r030653a 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:32202013 // Update Count : 6 5412 // Last Modified On : Wed Jun 17 16:13:00 2020 13 // Update Count : 663 14 14 // 15 15 … … 20 20 21 21 #include <time.h> // timespec 22 extern "C" {23 22 #include <sys/time.h> // timeval 24 }25 23 #include <time_t.hfa> // Duration/Time types 26 24 … … 91 89 int64_t ?`w( Duration dur ) { return dur.tn / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); } 92 90 91 double ?`dns( Duration dur ) { return dur.tn; } 92 double ?`dus( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000_000.); } 93 double ?`dms( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000.); } 94 double ?`ds( Duration dur ) { return dur.tn / (double)TIMEGRAN; } 95 double ?`dm( Duration dur ) { return dur.tn / (60. * TIMEGRAN); } 96 double ?`dh( Duration dur ) { return dur.tn / (60. * 60. * (double)TIMEGRAN); } 97 double ?`dd( Duration dur ) { return dur.tn / (24. * 60. * 60. * (double)TIMEGRAN); } 98 double ?`dw( Duration dur ) { return dur.tn / (7. * 24. * 60. * 60. * (double)TIMEGRAN); } 99 93 100 Duration max( Duration lhs, Duration rhs ) { return (lhs.tn < rhs.tn) ? rhs : lhs;} 94 101 Duration min( Duration lhs, Duration rhs ) { return !(rhs.tn < lhs.tn) ? lhs : rhs;} -
tests/.expect/time.txt
rc1ee231 r030653a 1 1 10800 2 3.375 12 1.00001 2 0.125 0.0333333333333333 3.375 12000. 1000010. 2 3 0 2 3.375 3 4 7 7 7 -
tests/time.cfa
rc1ee231 r030653a 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 18:27:37202013 // Update Count : 3 412 // Last Modified On : Thu Jun 18 18:14:49 2020 13 // Update Count : 37 14 14 // 15 15 … … 20 20 Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns; 21 21 sout | d1 | d2 | d3 | d4 | d5; 22 sout | d1`dd | d2`dm | d3`ds | d4`dms | d5`dus; 22 23 d1 = 0; 23 24 sout | d1 | d2 | d3;
Note: See TracChangeset
for help on using the changeset viewer.