UTCTime and GeneralizedTime clean-up and comment v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 11 Jul 2021 00:44:15 +0200
branchv_0
changeset 29 c232d8b8efbf
parent 28 fade2f562970
child 30 e27e133731ee
UTCTime and GeneralizedTime clean-up and comment
src/lib/BasicASN1Reader.h
--- a/src/lib/BasicASN1Reader.h	Mon Jul 05 19:31:25 2021 +0200
+++ b/src/lib/BasicASN1Reader.h	Sun Jul 11 00:44:15 2021 +0200
@@ -195,14 +195,7 @@
 			ASN1ContentHandler::DateTime dateTime;
 
 			std::smatch match;
-			if (std::regex_match(s, match, std::regex("([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})?(Z|([+-][0-9]{2})'?([0-9]{2})'?)"))) {
-				// Supported UTCTime formats:
-				// YYMMDDhhmmZ
-				// YYMMDDhhmmssZ
-				// YYMMDDhhmm+hhmm
-				// YYMMDDhhmm-hhmm
-				// YYMMDDhhmmss+hhmm
-				// YYMMDDhhmmss-hhmm
+			if (std::regex_match(s, match, std::regex("([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})?(Z|([+-][0-9]{2})([0-9]{2}))"))) {
 				int i = 1;
 				uint32_t year = std::stoi(match[i++]);
 				dateTime.year = year < 50 ? 2000 + year : 1900 + year;
@@ -231,7 +224,8 @@
 			ASN1ContentHandler::DateTime dateTime;
 
 			std::smatch match;
-			if (std::regex_match(s, match, std::regex("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})(\\.([0-9]{1,3}))?(Z|([+-][0-9]{2})'?([0-9]{2})'?)"))) {
+			if (std::regex_match(s, match, std::regex("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})(\\.([0-9]{1,3}))?(Z|([+-][0-9]{2})([0-9]{2}))"))) {
+				// TODO: support also fractions of minutes and hours in GeneralizedTime
 				int i = 1;
 				dateTime.year = std::stoi(match[i++]);
 				dateTime.month = std::stoi(match[i++]);