/********************************** * * Ut to Tt TIME CHECK TEST MAIN * * testWUTC2TT YYYYMMDDhhmmssmsmsmsususus * **********************************/ #include #include #include #include "TiTm_type.h" #include "Com_type.h" int main( argc, argv ) int32_t argc; char *argv[]; { char a_ut[21], aa_ut[21]; char cwk[30], *fname; uint8_t b_ut[11], bb_ut[11]; char *Leap_FNAME; int leng = 20; int N1 = 1; int rtn, i; int ir; double Ttsec = 0.0; int yy, mm, dd; static int month[12]={31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /*------------------------------------------------------*/ if( argc != 2 ) { printf( "Usage : testWUTC2TT YYYYMMDDhhmmssmmmuuu\n" ); exit(1); } if( strlen(argv[1]) != 20 ) { printf( "YYYYMMDDhhmmssmmmuuu length(20) error\n" ); exit(1); } if( fname = getenv( "TM_LEAP_FPATH" ) ); else { printf( "environment error :TM_LEAP_FPATH\n" ); exit(1); } strcpy( a_ut, argv[1] ); strcpy( aa_ut, argv[1] ); /*------------------------------------------------------*/ /* トータル日算出 */ memset( cwk, 0x00, sizeof(cwk) ); memcpy( cwk, a_ut, 4 ); yy = atoi( cwk ); memset( cwk, 0x00, sizeof(cwk) ); memcpy( cwk, &a_ut[4], 2 ); mm = atoi( cwk ); memset( cwk, 0x00, sizeof(cwk) ); memcpy( cwk, &a_ut[6], 2 ); dd = atoi( cwk ); for( i=0; i BCD ERROR !\n"); exit(1); } printf( "BCDUT2TT IN : Ut(BCD)[%02x%02x.%02x.%02x %02x:%02x:%02x %02x%02x%02x]\n", b_ut[0],b_ut[1],b_ut[2],b_ut[3],b_ut[4],b_ut[5],b_ut[6],b_ut[7],b_ut[8],b_ut[9]); rtn = BCDUT2TT( 1, b_ut, &Ttsec ); printf( "BCDUT2TT OUT : rtn[%d] Tt[%lf] \n", rtn, Ttsec); rtn = com_ascbcd_( aa_ut, bb_ut, &leng, &ir, &N1, &N1); if( rtn < 0 ){ printf("ASCII -> BCD ERROR !\n"); exit(1); } printf( "BCDUT2TT IN : Ut(BCD)[%02x%02x.%02x%02x %02x:%02x:%02x %02x%02x%02x]\n", bb_ut[0],bb_ut[1],bb_ut[2],bb_ut[3],bb_ut[4],bb_ut[5],bb_ut[6],bb_ut[7],bb_ut[8],bb_ut[9]); rtn = BCDUT2TT( 2, bb_ut, &Ttsec ); printf( "BCDUT2TT OUT : rtn[%d] Tt[%lf] \n", rtn, Ttsec); }