Date and Time in RFC 3339 format
Moderator: Klaus
-
- Posts: 58
- Joined: Mon Oct 28, 2013 1:23 pm
Date and Time in RFC 3339 format
Is there a way to transform the livecode date and time information into the Internet format RFC 3339?
I am working with this type of data and want to know if I have to write an own function for it or if it is planned to have it as another date-time format in Livecode?
Kind regards,
Torsten
I am working with this type of data and want to know if I have to write an own function for it or if it is planned to have it as another date-time format in Livecode?
Kind regards,
Torsten
Re: Date and Time in RFC 3339 format
Could you give us an example, so we do not need to read the whole RFC 3339? 

Re: Date and Time in RFC 3339 format
I doubt it is on the roadmap to have RFC 3339 format dates in LiveCode very soon, or at least if it is and implemented before fixing the pre 1970 date bug on Windows then I will be surprised, as well as very upset.
https://quality.livecode.com/show_bug.cgi?id=4941
(As this report is dated 2007, you can understand my scepticism.)
https://quality.livecode.com/show_bug.cgi?id=4941
(As this report is dated 2007, you can understand my scepticism.)
-
- Posts: 58
- Joined: Mon Oct 28, 2013 1:23 pm
Re: Date and Time in RFC 3339 format
A typical example is this one:
2019-07-10T18:27:07.744Z
It is the standard format for many internet service timestamps.
YYYY-MM-DDTHH:MM:SS.fff (Z = UTC = Universal Time Coordinated)
It shouldn't be too complicated to implement into the engine. Until then, I will have to write my own translator for it...
2019-07-10T18:27:07.744Z
It is the standard format for many internet service timestamps.
YYYY-MM-DDTHH:MM:SS.fff (Z = UTC = Universal Time Coordinated)
It shouldn't be too complicated to implement into the engine. Until then, I will have to write my own translator for it...
Re: Date and Time in RFC 3339 format
Aha, thank you.
Maybe you could add a comment to the above mentioned report, Torsten?
Maybe you could add a comment to the above mentioned report, Torsten?
Re: Date and Time in RFC 3339 format
You could use (the components of) the internet date.TorstenHolmer wrote:Is there a way to transform the livecode date and time information into the Internet format RFC 3339?
[The optional fractional seconds can be derived from the millisecs.]
p.s. There is also https://github.com/derbrill/libdate
shiftLock happens
Re: Date and Time in RFC 3339 format
Without even understanding the format of this date, surely a handler that dissects each component, using our favorite property, the itemDelimiter, can be easily written and stored as a library function.
Craig
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Date and Time in RFC 3339 format
True, Craig, but being able to use the format with the convert, sort, and other commands would be pretty nice.
Mark Waddingham once outlined a proposal to support a wide range of date formats with minimal modifications to the code base. That was many years ago. Don't know what became of that, but it sure sounded useful in our world where every other week a new RFC comes out with a new date format because I guess the nature time keeps changing so all of the vast range of existing formats are somehow no longer adequate.
Mark Waddingham once outlined a proposal to support a wide range of date formats with minimal modifications to the code base. That was many years ago. Don't know what became of that, but it sure sounded useful in our world where every other week a new RFC comes out with a new date format because I guess the nature time keeps changing so all of the vast range of existing formats are somehow no longer adequate.

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 58
- Joined: Mon Oct 28, 2013 1:23 pm
Re: Date and Time in RFC 3339 format
Ok, I've developed a solution and want to share it here:
Code: Select all
function ConvertInternetTimeToSeconds tInternetTime
-- IN: 2019-07-11T15:15:22.801Z
-- OUT: 1562858122
set itemdelimiter to "T"
put item 1 of tInternetTime into tDate
put item 2 of tInternetTime into tTime
set itemdelimiter to "-"
put item 1 of tDate into tYear
put item 2 of tDate into tMonth
put item 3 of tDate into tDay
set itemdelimiter to ":"
put item 1 of tTime into tHour
put item 2 of tTime into tMinute
put item 3 of tTime into tSecond
set itemdelimiter to "."
put item 1 of tSecond into tSecond
put tYear & comma & tMonth & comma & tDay & comma & tHour & comma & tMinute & comma & tSecond & comma & "1" into tTimeInSeconds
set itemdelimiter to comma
add 2 to item 4 of tTimeInSeconds -- local adaption to UTC: my timezone is 2 hours behind ZULU time
convert tTimeInSeconds from dateItems to seconds
return tTimeInSeconds
end ConvertInternetTimeToSeconds
Re: Date and Time in RFC 3339 format
For the first part of your function you could also use a one-liner:
Code: Select all
function ConvertInternetTimeToDateItems tInternetTime
return item 1 to 6 of replaceText(tInternetTime,"[-T:.]",",")
end ConvertInternetTimeTodateItems
shiftLock happens
-
- Posts: 58
- Joined: Mon Oct 28, 2013 1:23 pm
Re: Date and Time in RFC 3339 format
Great idea!
Thanks Hermann
Thanks Hermann
