1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/iso_datetime.md

92 lines
2.1 KiB
Markdown
Raw Normal View History

2022-07-20 17:09:09 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iso_datetime"></a>
# jc.parsers.iso\_datetime
jc - JSON Convert ISO 8601 Datetime string parser
This parser supports standard ISO 8601 strings that include both date and
time. If no timezone or offset information is available in the sring, then
UTC timezone is used.
Usage (cli):
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime
Usage (module):
import jc
2022-07-22 09:28:27 -07:00
result = jc.parse('iso_datetime', iso_8601_string)
2022-07-20 17:09:09 -07:00
Schema:
{
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
2022-07-21 10:16:58 -07:00
"microsecond": integer,
2022-07-20 17:09:09 -07:00
"period": string,
"utc_offset": string,
"day_of_year": integer,
"week_of_year": integer,
"iso": string,
2022-07-20 23:02:16 -07:00
"timestamp": integer # [0]
2022-07-20 17:09:09 -07:00
}
2022-07-20 23:02:16 -07:00
[0] timezone aware UNIX timestamp expressed in UTC
2022-07-20 17:09:09 -07:00
Examples:
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
{
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 20,
"weekday": "Wed",
"weekday_num": 3,
"hour": 2,
"hour_24": 14,
"minute": 52,
"second": 45,
2022-07-21 10:16:58 -07:00
"microsecond": 0,
2022-07-20 17:09:09 -07:00
"period": "PM",
"utc_offset": "+0000",
"day_of_year": 201,
"week_of_year": 29,
"iso": "2022-07-20T14:52:45+00:00",
"timestamp": 1658328765
}
<a id="jc.parsers.iso_datetime.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)