tools: fw-update: allow ISO 8610 date formats

Currently, the ReleaseDateTime data is expected to be in a
"%d/%m/%Y %H:%M:%S" format.

However, this is ambiguous (ie., is locale-specific).

This change adds supoort to allow an ISO 8601 format of:

 "%Y-%m-%dT%H:%M:%S"

and a relaxed version with the 'T' separator replaced with a space:

 "%Y-%m-%d %H:%M:%S"

Update the readme and example json to switch to the preferred format.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Change-Id: Ica3ae824979df6b666b8abb619ceaedffd90b374
diff --git a/tools/fw-update/README.md b/tools/fw-update/README.md
index b59b403..a320b2b 100644
--- a/tools/fw-update/README.md
+++ b/tools/fw-update/README.md
@@ -59,8 +59,9 @@
 - PackageHeaderFormatRevision: Supported, must be specified in metadata file
 - PackageHeaderSize: Supported, generated by the script
 - PackageReleaseDateTime: Supported, this is an optional field in the metadata
-  file and the format is dd/MM/yyyy HH:mm:ss. If not specified in the metadata
-  file, current time is taken.
+  file and the format is YYYY-MM-DD HH:mm:ss (or with the space replaced with a
+  'T' for full ISO-8601 compliance). If not specified in the metadata file,
+  current time is taken.
 - ComponentBitmapBitLength: Supported, generated by the script
   - Only 32 components supported at the moment
 - PackageVersionStringType: Supported - only ASCII at the moment. Generated by
diff --git a/tools/fw-update/metadata-example.json b/tools/fw-update/metadata-example.json
index ac080af..f6d65d8 100644
--- a/tools/fw-update/metadata-example.json
+++ b/tools/fw-update/metadata-example.json
@@ -2,7 +2,7 @@
     "PackageHeaderInformation": {
         "PackageHeaderIdentifier": "F018878CCB7D49439800A02F059ACA02",
         "PackageHeaderFormatVersion": 1,
-        "PackageReleaseDateTime": "25/12/2021 00:00:00",
+        "PackageReleaseDateTime": "2021-12-25 00:00:00",
         "PackageVersionString": "VersionString1"
     },
     "FirmwareDeviceIdentificationArea": [
diff --git a/tools/fw-update/pldm_fwup_pkg_creator.py b/tools/fw-update/pldm_fwup_pkg_creator.py
index 0209f1a..b61afa5 100755
--- a/tools/fw-update/pldm_fwup_pkg_creator.py
+++ b/tools/fw-update/pldm_fwup_pkg_creator.py
@@ -186,9 +186,22 @@
     )
 
     if release_date_time_str is not None:
-        release_date_time = datetime.strptime(
-            release_date_time_str, "%d/%m/%Y %H:%M:%S"
-        )
+        formats = [
+            "%Y-%m-%dT%H:%M:%S",
+            "%Y-%m-%d %H:%M:%S",
+            "%d/%m/%Y %H:%M:%S",
+        ]
+        release_date_time = None
+        for fmt in formats:
+            try:
+                release_date_time = datetime.strptime(
+                    release_date_time_str, fmt
+                )
+                break
+            except ValueError:
+                pass
+        if release_date_time is None:
+            sys.exit("Can't parse release date '%s'" % release_date_time_str)
     else:
         release_date_time = datetime.now()