Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/time.cfa

    ref346f7c rff2a33e  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec 23 22:57:48 2018
    13 // Update Count     : 57
     12// Last Modified On : Sat Jul 13 08:41:55 2019
     13// Update Count     : 65
    1414//
    1515
    1616#include "time.hfa"
    17 #include "iostream.hfa"
     17#include "fstream.hfa"
    1818#include <stdio.h>                                                                              // snprintf
    1919#include <assert.h>
     
    3737                if ( ns != 0 ) {                                                                // some ?
    3838                        char buf[16];
    39                         (ostype &)(os | nanomsd( ns, buf ));                    // print nanoseconds
     39                        (ostype &)(os | nanomsd( ns, buf ));            // print nanoseconds
    4040                } // if
    4141                return os;
     
    4343
    4444        void ?|?( ostype & os, Duration dur ) with( dur ) {
    45                 (ostype &)(os | dur); nl( os );
     45                (ostype &)(os | dur); ends( os );
    4646        } // ?|?
    4747} // distribution
     
    5252
    5353#ifdef __CFA_DEBUG__
    54 #define CreateFmt "Attempt to create Time( year=%d (>=1970), month=%d (1-12), day=%d (1-31), hour=%d (0-23), min=%d (0-59), sec=%d (0-60), nsec=%d (0-999_999_999), " \
    55         "which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038."
     54static void tabort( int year, int month, int day, int hour, int min, int sec, int nsec ) {
     55        abort | "Attempt to create Time( year=" | year | "(>=1970), month=" | month | "(1-12), day=" | day | "(1-31), hour=" | hour | "(0-23), min=" | min | "(0-59), sec=" | sec
     56                  | "(0-60), nsec=" | nsec | "(0-999_999_999), which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038.";
     57} // tabort
    5658#endif // __CFA_DEBUG__
    5759
     
    6365#ifdef __CFA_DEBUG__
    6466        if ( month < 1 || 12 < month ) {
    65                 abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
     67                tabort( year, month, day, hour, min, sec, nsec );
    6668        } // if
    6769#endif // __CFA_DEBUG__
     
    6971#ifdef __CFA_DEBUG__
    7072        if ( day < 1 || 31 < day ) {
    71                 abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
     73                tabort( year, month, day, hour, min, sec, nsec );
    7274        } // if
    7375#endif // __CFA_DEBUG__
     
    7981#ifdef __CFA_DEBUG__
    8082        if ( epochsec == (time_t)-1 ) {
    81                 abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
     83                tabort( year, month, day, hour, min, sec, nsec );
    8284        } // if
    8385#endif // __CFA_DEBUG__
     
    8587#ifdef __CFA_DEBUG__
    8688        if ( tv > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
    87                 abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
     89                tabort( year, month, day, hour, min, sec, nsec );
    8890        } // if
    8991#endif // __CFA_DEBUG__
     
    150152                long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
    151153                if ( ns == 0 ) {                                                                // none ?
    152                         (ostype &)(os | buf);                                                   // print date/time/year
     154                        (ostype &)(os | buf);                                           // print date/time/year
    153155                } else {
    154156                        buf[19] = '\0';                                                         // truncate to "Wed Jun 30 21:49:08"
    155157                        char buf2[16];
    156158                        nanomsd( ns, buf2 );                                            // compute nanoseconds
    157                         (ostype &)(os | buf | buf2 | ' ' | &buf[20]);   // print date/time, nanoseconds and year
     159                        (ostype &)(os | buf | buf2 | ' ' | &buf[20]); // print date/time, nanoseconds and year
    158160                } // if
    159161                return os;
     
    161163
    162164        void ?|?( ostype & os, Time time ) with( time ) {
    163                 (ostype &)(os | time); nl( os );
     165                (ostype &)(os | time); ends( os );
    164166        } // ?|?
    165167} // distribution
Note: See TracChangeset for help on using the changeset viewer.