问题
this is a start:
>
> XQUERY fn:parse-ietf-date('Tue, 18 Jun 2019 13:10:56 GMT')
2019-06-18T13:10:56Z
Query executed in 425.5 ms.
>
from the basex console. need to apply to the query for a searchable date. see also:
Inverse function to format-date
Google chat, or "hangouts" exports its data as JSON. The dates are in UTC as a String, looking at least similar to:
Thursday, 17-Dec-20 14:29:33 UTC in RFC 2822 https://www.unixtimestamp.com/
Assuming RFC 2822, or similar, then how would that String be imported or stored or translated as a Date "type" of "object"? In order to search by date.
Something like:
<xs:element name="start" type="xs:date"/>
or at least conforming to that schema. Not looking to validate the data per se, just search it. Such a namespace and type is, presumably, more easily searched.
importing the data (for context):
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$ ls
group_info.json import.xq messages.json
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$ cat import.xq
let $database := "messages"
for $name in file:list('.', false(), '*.json')
let $file := file:read-text($name)
let $json := json:parse($file)
return db:add($database, $json, $name)
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$ basex import.xq
nicholas@mordor:~/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e$
example output:
nicholas@mordor:~/flwor/hangouts$
nicholas@mordor:~/flwor/hangouts$ basex dates.xq
<created__date>Thursday, 4 June 2020 at 13:27:14 UTC</created__date>nicholas@mordor:~/flwor/hangouts$
nicholas@mordor:~/flwor/hangouts$
which looks to be RFC 2822 formatted date String data. Here, one arbitrary date was output with:
let $database := db:open("messages")
let $date := $database/json/messages/_/created__date
return $date[33]
which is where the messages were imported to.
来源:https://stackoverflow.com/questions/65342726/how-to-parse-a-date-and-time-timestamp-to-query-for-a-range-with-xml