// file: $(NEDC_NFC)/class/cpp/Wfdb/wfdb_02.cc // // This file contains private methods. // // Revision History: // // 20240410 (JP): initial version // // local include files // #include "Wfdb.h" //***************************************************************************** // // private methods: convert_date and convert_string // //***************************************************************************** // method: convert_date // // arguments: // char* odate1: the converted date in DD-MMM-YYYY format (output) // char* odate2: the converted date in DD.MM.YY format (output) // char* idate: the original date (input) // // return: a boolean value indicating status // // This method converts dates in the format "DD/MM/YY" to "DD-MMM-YYYY" // and "DD.MM.YY". // bool Wfdb::convert_date(char* odate1_a, char* odate2_a, char* idate_a) { // declare a mapping of the numeric value of month to the name // const char * months[12] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; // copy the argument because strtok destroys it // char tmp_string[strlen(idate_a) + 1]; strcpy(tmp_string, idate_a); // parse the string for the day // char* token = strtok(tmp_string, Itgl::SLASH); char* DD = token; // parse the string for the month // token = strtok(NULL, Itgl::SLASH); long MM = atoi(token); // parse the string for the year // token = strtok(NULL, Itgl::SLASH); char* YY = token; // create the output format using DD-MMM-YYYY // sprintf(odate1_a, "%2s-%3s-%4s", DD, months[MM - 1], YY); // create the output format using DD.MM.YY: zero pad // sprintf(odate2_a, "%2s.%02ld.%2s", DD, MM, YY + 2); // exit gracefully // return true; } // method: convert_time // // arguments: // char* otime: the converted time (output) // char* itime: the original time (input) // // return: a boolean value indicating status // // This method converts time to a format of 00.00.00. // bool Wfdb::convert_time(char* otime_a, char* itime_a) { // copy the argument because strtok destroys it // char tmp_string[strlen(itime_a) + 1]; strcpy(tmp_string, itime_a); // parse the string for the hours // char* token = strtok(tmp_string, Itgl::COLON); char* HH = token; // parse the string for the minutes // token = strtok(NULL, Itgl::COLON); char* MM = token; // parse the string for the seconds // token = strtok(NULL, Itgl::COLON); char* SS = token; // create the output format using DD-MMM-YYYY // sprintf(otime_a, "%2s.%2s.%2s", HH, MM, SS); // exit gracefully // return true; } // // end of file