// class_current_date_extra.h (c) 1999 Kari Laitinen // This file is similar to class_current_date.h but here // we calculate days, months, years, etc. without using // the localtime function of time.h. // Class Date must be included before this file because // class Current_date inherits Date. This file requires // also the inclusion of time.h. class Current_date : public Date { public: Current_date( char given_date_print_format = 'A' ) ; } ; Current_date::Current_date( char given_date_print_format ) { time_t seconds_to_decrement ; time( &seconds_to_decrement ) ; // seconds_to_decrement contains now the seconds that have // elapsed since 1.1.1970 at 00:00:00 o'clock. // We can calculate the current date from these seconds // when we know that every day consists of 86400 secons. Date date_to_increment( 1, 1, 1970 ) ; while ( seconds_to_decrement >= 86400 ) { date_to_increment.increment() ; seconds_to_decrement = seconds_to_decrement - 86400 ; } this_day = date_to_increment.day() ; this_month = date_to_increment.month() ; this_year = date_to_increment.year() ; date_print_format = given_date_print_format ; }