yan zhang
/
NB_CLOCK_180505
clock
Diff: myScope/mybc95.cpp
- Revision:
- 2:e54d9d87c6cb
- Parent:
- 1:013b9fdc4e78
- Child:
- 3:b8766d623f01
diff -r 013b9fdc4e78 -r e54d9d87c6cb myScope/mybc95.cpp --- a/myScope/mybc95.cpp Sat May 12 03:03:14 2018 +0000 +++ b/myScope/mybc95.cpp Mon May 14 00:04:42 2018 +0000 @@ -73,18 +73,21 @@ Desc.: Auth. Vesion:2017.7.2 *****************************/ -void bc95Act::get_tim(void) +char *bc95Act::get_tim(void) { + static char buf_tim[7]=""; tm *tim; time_t seconds=time(NULL); tim=localtime(&seconds); - buf_bc95Tx[0]=char(tim->tm_year-100); - buf_bc95Tx[1]=char(tim->tm_mon); - buf_bc95Tx[2]=char(tim->tm_mday); - buf_bc95Tx[3]=char(tim->tm_hour); - buf_bc95Tx[4]=char(tim->tm_min); - buf_bc95Tx[5]=char(tim->tm_sec); + buf_tim[0]=char(tim->tm_year-100); + buf_tim[1]=char(tim->tm_mon); + buf_tim[2]=char(tim->tm_mday); + buf_tim[3]=char(tim->tm_hour); + buf_tim[4]=char(tim->tm_min); + buf_tim[5]=char(tim->tm_sec); + + return buf_tim; } /***************************** @@ -126,29 +129,17 @@ set_time(secc); } -void bc95Act::changdate (void) +void bc95Act::changdate(void) { - unsigned char temp1=0; - - int i; - - for(temp1=0; temp1<27; temp1++) { - year= (buf[temp1+5]-0x30)*10+(buf [temp1+6]-0x30)+2000; //年 - mon = (buf[temp1+8]-0x30)*10+(buf [temp1+9]-0x30); //月 - day = (buf[temp1+11]-0x30)*10+(buf [temp1+12]-0x30); //日 - - if((buf[temp1+23]== '0') && (buf [temp1+24] == '0')) //UTC - hour =(buf[temp1+14]-0x30)*10+(buf [temp1+15]-0x30)+8; //时 - else if((buf[temp1+23]== '0') && (buf [temp1+24] == '8')) //EAST 8 - hour=(buf[temp1+14]-0x30)*10+(buf[temp1+15]-0x30); - else hour=(buf[temp1+14]-0x30)*10+(buf[temp1+15]-0x30)+8; - min=(buf[temp1+17]-0x30)*10+(buf[temp1+18]-0x30); //分 - sec= (buf[temp1+20]-0x30)*10+(buf[temp1+21]-0x30); //秒 - } - for(i=0; i<27; i++) buf[i]=0; + year= (buf_bc95Rx[5]-0x30)*10+(buf_bc95Rx[6]-0x30)+2000; //年 + mon = (buf_bc95Rx[8]-0x30)*10+(buf_bc95Rx[9]-0x30); //月 + day = (buf_bc95Rx[11]-0x30)*10+(buf_bc95Rx[12]-0x30); //日 + hour= (buf_bc95Rx[14]-0x30)*10+(buf_bc95Rx[15]-0x30); //时 + min = (buf_bc95Rx[17]-0x30)*10+(buf_bc95Rx[18]-0x30); //分 + sec = (buf_bc95Rx[20]-0x30)*10+(buf_bc95Rx[21]-0x30); //秒 } -uint32_t bc95Act::changsec (void) +uint32_t bc95Act::changsec(void) { uint16_t t; uint32_t seccount=0;