By running the command
wmic OS Get LastBootUpTime
I get time in string UTC time format YYYYMMDDHHMMSS.MMMMMMSUTC
. If string is known to be timestamp, then convert it to timestamp format:
typedef struct _Timestamp { unsigned int year; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int second; unsigned int microseconds; signed int utc; } Timestamp;
Eg: Time: 20210324111750.500000+330
if isTimestamp = true.
Timestamp.year = 2021 Timestamp.month = 03 Timestamp.day = 24 Timestamp.hour = 11 Timestamp.minute = 17 Timestamp.second = 50 Timestamp.microseconds = 500000 Timestamp.utc = +330
If it is known to be in interval, convert string from DDDDDDDDHHMMSS.MMMMMM:000
format to interval format:
typedef struct _Interval { unsigned int days; unsigned int hours; unsigned int minutes; unsigned int seconds; unsigned int microseconds; unsigned int __padding1; unsigned int __padding2; unsigned int __padding3; } Interval;
Eg: Time: 00000324111750.500000:000
if isTimestamp = false.
Interval.days = 324 Interval.hours = 11 Interval.minutes = 17 Interval.seconds = 50 Interval.microseconds = 500000 Interval.__padding1 = 0 Interval.__padding2 = 0 Interval.__padding3 = 0
Manually parsing the string seems to be a very long approach.
Can someone suggest C inbuilt functions to achieve this. or If there are functions readily available to convert char *
to the above time formats.
没有评论:
发表评论