Changeset d0c91a6 for tests/time.cfa
- Timestamp:
- Jan 15, 2019, 4:16:15 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- c802eb88
- Parents:
- 5e49e47 (diff), c9aba81 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/time.cfa
r5e49e47 rd0c91a6 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Nov 6 18:01:45201813 // Update Count : 1712 // Last Modified On : Thu Dec 20 23:09:21 2018 13 // Update Count : 23 14 14 // 15 15 … … 19 19 int main() { 20 20 Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns; 21 sout | d1 | d2 | d3 | d4 | d5 | endl;21 sout | d1 | d2 | d3 | d4 | d5; 22 22 int i; 23 23 d1 = 0; 24 sout | d1 | d2 | d3 | endl;24 sout | d1 | d2 | d3; 25 25 d1 = 7`s; 26 26 d3 = d2 = d1; 27 sout | d1 | d2 | d3 | endl;27 sout | d1 | d2 | d3; 28 28 d1 = d1 + d2; 29 sout | d1 | endl;30 sout | d1 == 7`s | d1 == d2 | d1 == 0 | endl;31 sout | div( 7`s, 2`s ) | endl;32 sout | endl;29 sout | d1; 30 sout | d1 == 7`s | d1 == d2 | d1 == 0; 31 sout | div( 7`s, 2`s ); 32 sout | nl; 33 33 34 34 Time t = { 1970, 1, 2, 0, 0, 0, 10_000_000 }; 35 sout | t | endl;35 sout | t; 36 36 t = t + d1; 37 sout | t | t.tv | endl;37 sout | t | t.tv; 38 38 Time t1 = (timespec){ 104_414, 10_000_000 }; 39 sout | t1 | t1.tv | endl;40 sout | t - t | t + d5 | t.tv | endl;39 sout | t1 | t1.tv; 40 sout | t - t | t + d5 | t.tv; 41 41 char buf[16]; 42 sout | "yy/mm/dd" | [t, buf]`ymd ;// shared buf => separate calls43 sout | "mm/dd/yy" | mm_dd_yy( t, buf ) ;42 sout | "yy/mm/dd" | [t, buf]`ymd | nonl; // shared buf => separate calls 43 sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl; 44 44 strftime( buf, 16, "%D", t ); // %D => mm/dd/yy 45 sout | "mm/dd/yy" | buf ;46 sout | "dd/yy/mm" | [t, buf]`dmy | endl;45 sout | "mm/dd/yy" | buf | nonl; 46 sout | "dd/yy/mm" | [t, buf]`dmy; 47 47 Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 }; 48 sout | t2 | t2.tv | endl | t3 | t3.tv | endl;49 sout | endl;48 sout | t2 | t2.tv | nl | t3 | t3.tv; 49 sout | nl; 50 50 51 51 // Clock Newfoundland = { -3.5`h }, PST = { -8`h }; // distance from GMT (UTC) 52 // sout | "Clock Resolution" | getRes() | endl53 // | "Newfoundland" | getTime( Newfoundland ) | endl54 // | "local" | getTime() | endl55 // | "local nsec" | getTimeNsec() | endl56 // | "PST" | PST() | endl;// getTime short form57 // sout | endl;52 // sout | "Clock Resolution" | getRes() 53 // | "Newfoundland" | getTime( Newfoundland ) 54 // | "local" | getTime() 55 // | "local nsec" | getTimeNsec() 56 // | "PST" | PST(); // getTime short form 57 // sout | nl; 58 58 59 59 // http://en.cppreference.com/w/cpp/chrono/duration/operator_arith4 60 60 Duration s = 1`h + 2 * 10`m + 70`s / 10; 61 sout | "1 hour + 2*10 min + 70/10 sec = " | s | "seconds" | endl;62 sout | "Dividing that by 2 minutes gives" | s / 2`m | endl;63 sout | "Dividing that by 2 gives" | s / 2 | "seconds \n";64 sout | s | "seconds is" | s`h | "hours," | (s % 1`h)`m | "minutes," | (s % 1`m)`s | "seconds" | endl;61 sout | "1 hour + 2*10 min + 70/10 sec = " | s | "seconds"; 62 sout | "Dividing that by 2 minutes gives" | s / 2`m; 63 sout | "Dividing that by 2 gives" | s / 2 | "seconds"; 64 sout | s | "seconds is" | s`h | "hours," | (s % 1`h)`m | "minutes," | (s % 1`m)`s | "seconds"; 65 65 } // main 66 66
Note:
See TracChangeset
for help on using the changeset viewer.