Re: extracting date information from string
Posted: Wed Aug 31, 2022 12:29 pm
RFC = Rugby Football Club?
Beam me up, Scotty.
Beam me up, Scotty.
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
A relevant thread which references RFCs, with links, and includes some good ideas about possible future time and date options for LC from Mark Waddingham:
And the 'dirty' word is 'consistent' . . .But if those are all sturdy and consistent enough then they can be parsed.
Because they could be seconds, starting from the origin of time assigned by the OS (1904 Mac, 1970 'nix, etc.)dunbarx wrote: Wed Aug 31, 2022 2:29 pm I was wrong about integers. LC ( and HC) thinks that any floating point number is a date.
Well, they could, but I wonder if one can not be a bit more 'refined' and look forBecause they could be seconds
That is awkward.that is considered a single format
Yep, that is a great way into and out of the parsing jungle. Of course, some formats use "-".were one to set '/' as the itemDelimiter
Today is 31.8.2022 as far as I'm concerned.some formats use "-"
Using MacOS' data detectors is probably the best way to go about this if this is for Mac-only app, given the complexity.rodneyt wrote: Wed Aug 31, 2022 9:33 am In my case I'm building a MacOS (only) app, so the Applescript solution is interesting, given how well it seems to work in testing
Code: Select all
\s((?:0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:\d{4}|\d{2})|(?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](?:\d{4}|\d{2})|(?:\d{4})[^\w\d\r\n:](?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:[0-2][0-9]|3[0-1]))Code: Select all
put "\s((?:0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:\d{4}|\d{2})|(?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](?:\d{4}|\d{2})|(?:\d{4})[^\w\d\r\n:](?:0?[1-9]|1[0-2])[^\w\d\r\n:](?:[0-2][0-9]|3[0-1]))" into tRegex
get matchText(textToSearch, tRegex, R)