Date Time Expressions
Project description
Date Time Expression
dte
is a WIP date-time processing language with focus on broad interpretation and simplicity.
If you don't think it's intuitive, it's most likely unfinished.
It is strongly inspired by pdd.
How to use & What to know
pip install dte
Conventions
- Dates are always interpreted with highest units appearing before, e.g.:
2021-06-13
,2023 August 27
or2019 Jul 20
- Unix timestamps are both interpreted and output in seconds by default, but this is configurable
- When specifying time, just remember that
M
is for month andm
is for minute - Although english month and week-day names are always recognized, so are the names in the user's locale
Examples
date
dte 1752 Sep 1
- returns that date
dte 1752 September 1 12 AM
- returns that date time
dte today - 1957-12-26 in days
- returns 23273.0 at the time of writing
time
dte 12h:00 AM + 4h
- returns 16:00:00
dte 6 pm
- returns 18:00:00
dte 23h:23
- returns 23:23:00
dte 23m:23
- returns 00:23:23
The output format for time is configurable via the 'clock' key.
week days
dte monday
- returns the closest weekday date
dte last tuesday
- returns last tuesday's date
dte next tue
- returns next tuesday's date
dte 1611193453.dow
- returns wednesday
in UTC-03:00
the in
keyword
dte 1d in hours
- returns the amount of hours in a day
dte 1 day in hours
- returns the same as above
dte 1 hour 2 minutes in hours
- returns 1.0333333333333334
dte 1959 May 26 in unix
- returns the unix timestamp for the point in time
the until
keyword
dte seconds until 3000 Apr 10
- returns the amount of seconds until date
extremities
dte last sunday in 2021
- returns 2021-12-26
dte first sunday in 2021
- returns 2021-01-03
base date
dte days until Mar 2021
- returns the amount of days until the first day of base date
dte last sunday in Jan 2021
- returns 2021-01-31
operators
dte '2020 Jan 27 + 1y == 2021 Jan 26'
- returns True
dte '12h:00 AM != 12h:00 PM'
- returns True
delta declaration and operations
dte 1d
- declares a one day timedelta
dte 7y6M5w4d3h2m1s
- represents 2776 days, 3:02:00
dte 1d2m+2m+3h
- results in 1 day, 3:04:00
dte -100.5d
- accepts negative and/or floating point values
and in case you need it
dte help
- prints a detailed manual
locali(z|s)ation
dte 2020 Okt 10
- would be valid input if user's locale is German
Configuration File
dte
tries to read a config.json
file under config directory (~/.config/dte/
on Linux). In it you can set the following options:
{
"timestamp_unit": "<seconds|milliseconds>"
"clock": "<24|12>",
"datetime_output_format": "<ISO8601|<format>>"
"comparison_tolerance_seconds": <seconds>
}
Dependencies
- dateutil handles month and year's complex operations
- ply is a pure-Python implementation of the popular compiler construction tools lex and yacc
- appdirs for reading config file in a cross-platform manner
To do
- floating-point time units
- subtract delta from date
- add delta week month year
- help
- closest weekday
- python-like comparison
- wait(x)
- timestamp object
- next/last(weekday)
- add basedate point
- add
6 pm
- in keyword
-
first/last friday in 2014
- extremity -
first/last friday in April
- extremity -
first/last friday in next month
- extremity -
first/last friday in 2014 April
- extremity -
INTEGERth WEEKDAY IN BASEDATE
- extremity?
-
- until keyword
- format(timepoint, fmt) (in keyword) units given current time field
- add option
- to use custom locale
- to set unix timestamp format (seconds, millis, etc)
- add tab-completion for:
- months
- units given current datetime field or second hand of
in
keyword
- run tests across a variety of locales
- continuous integration
- parse month & abbrev
- parse weekday & abbrev
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.