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

110 lines
1.9 KiB
Markdown
Raw Normal View History

2020-07-31 14:39:02 -07:00
# jc.parsers.date
2020-08-05 16:51:58 -07:00
jc - JSON CLI output utility `date` command output parser
2020-07-31 14:39:02 -07:00
Calculated epoch time field is naive (i.e. based on the local time of the system the parser is run on) since there is no unambiguous timezone information in the `date` command output.
2020-08-05 13:32:59 -07:00
Usage (cli):
2020-07-31 14:39:02 -07:00
2020-08-05 16:51:58 -07:00
$ date | jc --date
or
$ jc date
2020-07-31 14:39:02 -07:00
2020-08-05 13:32:59 -07:00
Usage (module):
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
2020-07-31 14:39:02 -07:00
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ date | jc --date -p
{
"year": 2021,
"month_num": 3,
"day": 22,
"hour": 20,
"minute": 47,
"second": 3,
"period": null,
"month": "Mar",
"weekday": "Mon",
"weekday_num": 1,
"timezone": "PDT",
"epoch": 1616471223
2020-07-31 14:39:02 -07:00
}
2020-07-31 14:39:02 -07:00
$ date | jc --date -p -r
{
"year": "2021",
"month": "Mar",
"day": "22",
"weekday": "Mon",
"hour": "20",
"minute": "48",
"second": "12",
2020-07-31 14:39:02 -07:00
"timezone": "PDT"
}
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
2021-01-04 18:01:16 -08:00
proc_data: (Dictionary) raw structured data to process
2020-07-31 14:39:02 -07:00
Returns:
2020-07-31 14:47:06 -07:00
Dictionary. Structured data with the following schema:
2020-07-31 14:39:02 -07:00
{
2020-08-03 09:26:37 -07:00
"year": integer,
"month_num": integer,
"day": integer,
"hour": integer,
"minute": integer,
"second": integer,
"period": string,
2020-08-03 09:26:37 -07:00
"month": string,
"weekday": string,
"weekday_num": integer,
"timezone": string,
"epoch": integer
2020-07-31 14:39:02 -07:00
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
2020-07-31 14:47:06 -07:00
Dictionary. Raw or processed structured data.
2020-07-31 14:39:02 -07:00