iSPIRT / NPNT-Provisional-testing-tool

A simple and easy tool to perform a basic check of NPNT/ Digital Sky compliance. The App is a checklist to verify basic NPNT work and is limited to NPNT verification, PA, PIN check and Flight log signature Verification.
12 stars 20 forks source link

datetime string in permission artifact #14

Open rohang1997 opened 5 years ago

rohang1997 commented 5 years ago

as per the permission artefact that gets downloaded as a zipped file.

endtime and start time's string format is "2019-06-25T12:10:44.077239+05:30" to convert this string back into datetime.datetime() obj. there is function called strptime. So we can convert this string - c = dt.datetime.strptime(b,'%Y-%m-%dT%H:%M:%S.%f%z')

how ever the last term wont be able to parse unless it is converted from "+05:30" to "+0530" (colon removed). please refer to https://www.journaldev.com/23365/python-string-to-datetime-strptime

If you have some better method please do tell. Although it is easy to edit the string(removing colon) and use but it will be hectic if you change this in future. thank you . Also refer to this -

Problem

c = dt.datetime.strptime(b,'%Y-%m-%dT%H:%M:%S.%f%z') Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime (data_string, format)) ValueError: time data '2019-06-29T16:04:03.806120+05:30' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'

Resolution:

b '2019-06-29T16:04:03.806120+0530' c = dt.datetime.strptime(b,'%Y-%m-%dT%H:%M:%S.%f%z') c datetime.datetime(2019, 6, 29, 16, 4, 3, 806120, tzinfo=datetime.timezone(datetime.timedelta(0, 19800)))

If we clone the repo, and create the artifact offline - endtime is coming as : 2019-06-29 16:04:03.806120 (i.e. - local time)

small thing but look into it Thanks