Changeset 7030dab for tests/time.cfa


Ignore:
Timestamp:
Apr 6, 2020, 4:46:28 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
e3bc51c
Parents:
71d6bd8 (diff), 057298e (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.
Message:

Merge branch 'master' into new-ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/time.cfa

    r71d6bd8 r7030dab  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 20 23:09:21 2018
    13 // Update Count     : 23
     12// Last Modified On : Sun Jan  5 18:27:37 2020
     13// Update Count     : 34
    1414//
    1515
     
    2020        Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns;
    2121        sout | d1 | d2 | d3 | d4 | d5;
    22         int i;
    2322        d1 = 0;
    2423        sout | d1 | d2 | d3;
     
    3534        sout | t;
    3635        t = t + d1;
    37         sout | t | t.tv;
     36        sout | t | t`ns;
    3837        Time t1 = (timespec){ 104_414, 10_000_000 };
    39         sout | t1 | t1.tv;
    40         sout | t - t  | t + d5 | t.tv;
    41         char buf[16];
     38        sout | t1 | t1`ns;
     39        sout | t - t  | t + d5 | t`ns;
     40        char buf[64];
    4241        sout | "yy/mm/dd" | [t, buf]`ymd | nonl;                        // shared buf => separate calls
    4342        sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl;
     
    4645        sout | "dd/yy/mm" | [t, buf]`dmy;
    4746        Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 };
    48         sout | t2 | t2.tv | nl | t3 | t3.tv;
     47        sout | t2 | t2`ns | nl | t3 | t3`ns;
    4948        sout | nl;
    5049
     
    6362        sout | "Dividing that by 2 gives" | s / 2 | "seconds";
    6463        sout | s | "seconds is" | s`h | "hours," | (s % 1`h)`m | "minutes," | (s % 1`m)`s | "seconds";
     64
     65    t1 = (Time){ 2020, 1, 5, 9, 0, 0, 100000000000LL };
     66    t2 = (Time){ 1969, 13, 5, 9 };
     67    t3 = (Time){ 1970, 25, 366, 48, 120, -120, 60000000000LL };
     68    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t1 );
     69    sout | buf;
     70    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t2 );
     71    sout | buf;
     72    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t3 );
     73    sout | buf;
    6574} // main
    6675
Note: See TracChangeset for help on using the changeset viewer.