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

103 lines
1.6 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
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": 2020,
2020-08-03 09:26:37 -07:00
"month_num": 7,
2020-07-31 14:39:02 -07:00
"day": 31,
2020-08-03 09:26:37 -07:00
"hour": 16,
"minute": 48,
"second": 11,
"month": "Jul",
2020-07-31 14:39:02 -07:00
"weekday": "Fri",
2020-08-03 09:26:37 -07:00
"weekday_num": 6,
2020-07-31 14:39:02 -07:00
"timezone": "PDT"
}
$ date | jc --date -p -r
{
"year": "2020",
"month": "Jul",
"day": "31",
"weekday": "Fri",
2020-08-03 09:26:37 -07:00
"hour": "16",
"minute": "50",
"second": "01",
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:
proc_data: (dictionary) raw structured data to process
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,
"month": string,
"weekday": string,
"weekday_num": integer,
"timezone": string
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