Calculating 5-byte system time
John Sandgrounder (1650) 574 posts |
I have a need to calculate a 5 byte system time from an arbitrary string. I know that SYS “OS_ConvertStandardDateAndTime” will convert a standard 5 byte system time to a string. But how do I do it the other way in a Basic program? The string format for 10:05pm on 28th Jan is “20200128220500” My existing software ‘cheats’ by noting the 5 byte value at midnight each day – but that only works if the program is running at midnight! |
Jeffrey Lee (213) 6048 posts |
I don’t think there’s a string-to-time conversion SWI which allows you to specify a custom format string (the closest is Territory_ConvertTimeStringToOrdinals, which only accepts a handful of formats) However, since you appear to be dealing with a very straightforward numerals-only format, you could quite easily write some code which pulls apart the string and stores the values in an ordinals block which can then be used with Territory_ConvertOrdinalsToTime to convert to 5-byte time. |
John Sandgrounder (1650) 574 posts |
Thank You. I will try that. |
John Sandgrounder (1650) 574 posts |
Excellent: That is now working Thank You, again. |