@@ -812,16 +812,13 @@ static int has_epoch_timestamp(const char *nameline)
812
812
* 1970-01-01, and the seconds part must be "00".
813
813
*/
814
814
const char stamp_regexp [] =
815
- "^(1969-12-31|1970-01-01)"
816
- " "
817
- "[0-2][0-9]:[0-5][0-9]:00(\\.0+)?"
815
+ "^[0-2][0-9]:([0-5][0-9]):00(\\.0+)?"
818
816
" "
819
817
"([-+][0-2][0-9]:?[0-5][0-9])\n" ;
820
818
const char * timestamp = NULL , * cp , * colon ;
821
819
static regex_t * stamp ;
822
820
regmatch_t m [10 ];
823
- int zoneoffset ;
824
- int hourminute ;
821
+ int zoneoffset , epoch_hour , hour , minute ;
825
822
int status ;
826
823
827
824
for (cp = nameline ; * cp != '\n' ; cp ++ ) {
@@ -830,6 +827,18 @@ static int has_epoch_timestamp(const char *nameline)
830
827
}
831
828
if (!timestamp )
832
829
return 0 ;
830
+
831
+ /*
832
+ * YYYY-MM-DD hh:mm:ss must be from either 1969-12-31
833
+ * (west of GMT) or 1970-01-01 (east of GMT)
834
+ */
835
+ if (skip_prefix (timestamp , "1969-12-31 " , & timestamp ))
836
+ epoch_hour = 24 ;
837
+ else if (skip_prefix (timestamp , "1970-01-01 " , & timestamp ))
838
+ epoch_hour = 0 ;
839
+ else
840
+ return 0 ;
841
+
833
842
if (!stamp ) {
834
843
stamp = xmalloc (sizeof (* stamp ));
835
844
if (regcomp (stamp , stamp_regexp , REG_EXTENDED )) {
@@ -847,6 +856,9 @@ static int has_epoch_timestamp(const char *nameline)
847
856
return 0 ;
848
857
}
849
858
859
+ hour = strtol (timestamp , NULL , 10 );
860
+ minute = strtol (timestamp + m [1 ].rm_so , NULL , 10 );
861
+
850
862
zoneoffset = strtol (timestamp + m [3 ].rm_so + 1 , (char * * ) & colon , 10 );
851
863
if (* colon == ':' )
852
864
zoneoffset = zoneoffset * 60 + strtol (colon + 1 , NULL , 10 );
@@ -855,20 +867,7 @@ static int has_epoch_timestamp(const char *nameline)
855
867
if (timestamp [m [3 ].rm_so ] == '-' )
856
868
zoneoffset = - zoneoffset ;
857
869
858
- /*
859
- * YYYY-MM-DD hh:mm:ss must be from either 1969-12-31
860
- * (west of GMT) or 1970-01-01 (east of GMT)
861
- */
862
- if ((zoneoffset < 0 && memcmp (timestamp , "1969-12-31" , 10 )) ||
863
- (0 <= zoneoffset && memcmp (timestamp , "1970-01-01" , 10 )))
864
- return 0 ;
865
-
866
- hourminute = (strtol (timestamp + 11 , NULL , 10 ) * 60 +
867
- strtol (timestamp + 14 , NULL , 10 ) -
868
- zoneoffset );
869
-
870
- return ((zoneoffset < 0 && hourminute == 1440 ) ||
871
- (0 <= zoneoffset && !hourminute ));
870
+ return hour * 60 + minute - zoneoffset == epoch_hour * 60 ;
872
871
}
873
872
874
873
/*
0 commit comments