From d12558f0cae6798418961523d45280cfa6a63fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Sat, 11 Nov 2023 13:33:23 +0100 Subject: [PATCH] 2023-11-11 13:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/common/hbdate.c * accept timestamp values with trailing "Z" indicating UTC time (zero hour offset) --- ChangeLog.txt | 5 +++++ src/common/hbdate.c | 43 ++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 99ac0cf07b..5b5372ee90 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,11 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2023-11-11 13:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/common/hbdate.c + * accept timestamp values with trailing "Z" indicating UTC time + (zero hour offset) + 2023-11-09 15:07 UTC+0100 Phil Krylov (phil a t krylov.eu) * .github/workflows/linux-ci.yml * .github/workflows/macos-ci.yml diff --git a/src/common/hbdate.c b/src/common/hbdate.c index 382bc50ad2..4e8c903e72 100644 --- a/src/common/hbdate.c +++ b/src/common/hbdate.c @@ -545,27 +545,32 @@ HB_BOOL hb_timeStrGet( const char * szTime, } } } - while( HB_ISSPACE( *szTime ) ) + if( iBlocks > 0 && ( szTime[ 0 ] == 'Z' || szTime[ 0 ] == 'z' ) ) ++szTime; - if( ( szTime[ 0 ] == 'p' || szTime[ 0 ] == 'P' ) && - ( szTime[ 1 ] == 'm' || szTime[ 1 ] == 'M' ) ) - { - ++iBlocks; - szTime += 2; - if( iHour == 0 ) - iHour = 24; /* wrong time */ - else if( iHour != 12 ) - iHour += 12; - } - else if( ( szTime[ 0 ] == 'a' || szTime[ 0 ] == 'A' ) && - ( szTime[ 1 ] == 'm' || szTime[ 1 ] == 'M' ) ) + else { - ++iBlocks; - szTime += 2; - if( iHour == 0 ) - iHour = 24; /* wrong time */ - else if( iHour == 12 ) - iHour = 0; + while( HB_ISSPACE( *szTime ) ) + ++szTime; + if( ( szTime[ 0 ] == 'p' || szTime[ 0 ] == 'P' ) && + ( szTime[ 1 ] == 'm' || szTime[ 1 ] == 'M' ) ) + { + ++iBlocks; + szTime += 2; + if( iHour == 0 ) + iHour = 24; /* wrong time */ + else if( iHour != 12 ) + iHour += 12; + } + else if( ( szTime[ 0 ] == 'a' || szTime[ 0 ] == 'A' ) && + ( szTime[ 1 ] == 'm' || szTime[ 1 ] == 'M' ) ) + { + ++iBlocks; + szTime += 2; + if( iHour == 0 ) + iHour = 24; /* wrong time */ + else if( iHour == 12 ) + iHour = 0; + } } while( HB_ISSPACE( *szTime ) ) ++szTime;