Package: dte
Date Time Expressiondteis a WIP date-time processing language with focus on broad interpretation.If you don't think it's intuitive, it's most likely unfinished.It is strongly inspired bypdd.How to use & What to knowpip install dteConventionsWhen there is margin for ambiguity, expressions are always interpreted withhighest units appearing before, complying with ISO-8601, e.g.:2021-06-13,2023 August 27or2019 Jul 20Unix timestamps are both interpreted and output in seconds by default, but this is configurableWhen specifying time, just remember thatMis for month andmis for minuteConfiguration Filedtetries to read aconfig.jsonfile 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": <float>,
  "basedate_output_format": "%Y-%b",
  "decimal_places": <integer>
}Dependenciesdateutilhandles month and year's complex operationsplyis a pure-Python implementation of the popular compiler construction tools lex and yaccappdirsfor reading config file in a cross-platform mannerTo doformat(timepoint, fmt) (in keyword) units given current time fieldadd custom/OS locale support (?)add tab-completion for:monthsunits given current datetime field or RHS ofinkeyword"days until winter"run tests across a variety of localesaddshowfunctionshow clock for timeshow cal for date and basedateExamplesThe following examples are generated based on tests run, so many results will be relative to the day it was tested. Every expression on the left side is valid syntax.INPUTOUTPUTjan 1 + 99999M8334-04-011970 january 1st1970-01-01day 13 friday in 20212021-08-13friday day < 8 in Jan 20152015-01-02friday day 13 in August 2021.weekdayFridayfriday day 13 in August 20212021-08-132020-01-29 + (1 year + 1 month)2021-02-28days until Jan 20302936.18last sun in 20212021-12-26april+1M2022-05-01t+1d 08h302021-12-18 08:30:001am t == t 1amTrue1am t2021-12-17 01:00:00(2020-10-10+1d) 3pm2020-10-11 15:00:00t 1:00 == t 1amTruet 1:002021-12-17 01:00:00t 1am2021-12-17 01:00:00august2021-Aug4th wed in august2021-08-255th sunday in 20212021-01-314th sunday in 20212021-01-243rd sunday in 20212021-01-172nd sunday in 20212021-01-10-1d + 2020-10-102020-10-092014 Jan + 1M2014-02-01Jan 2014 + 1M2014-02-01seconds in 24h86400.00today==monFalsedays until mon2.18days until next mon2.18next mon + 1d2021-12-21monday+1d2021-12-21weekday t+100dSunday(weekday t+100d)==100d.weekdayTrue(weekday t+100d)Sundayweekday tmSaturdayyesterday==thuTrueyesterday==thursdayTruelast fri in Dec 20142014-12-26last fri in 2014 Dec2014-12-26last fri in 2014 December2014-12-26days until 2030-12-253294.186pm+1h19:00:002014 012014-Jan1st friday in april2022-04-01first friday in april2022-04-011st friday in next month2022-01-07first friday in next month2022-01-07next month2022-01-01seconds until 11 pm11736.53seconds until tomorrow15336.451996 August 28 9 AM1996-08-28 09:00:002s2s0:00:041 hour in seconds3600.001h in seconds3600.005m+5m0:10:001957-12-26 22:22:22 in unix-379118258yd-5h2021-12-15 19:00:001st sun in April 20212021-04-04first sun in April 20212021-04-041st friday in April 20142014-04-04first friday in April 20142014-04-04Jan 20142014-Janweekday 0Wednesdaywait until (n+.001s)``wait .001s``t - next Sunday-2 days, 0:00:002012-12-13-3y.weekdaySunday1st sunday in 20212021-01-03first sunday in 20212021-01-03last sunday in 20212021-12-26last Sunday != next sundayTruelast Sunday == next sundayFalsenext Sunday != last sundayTruenext Sunday == last sundayFalseseconds since 3000 Apr 10-30872463334.53seconds until 3000 Apr 1030872463334.452000-10-10 16:002000-10-10 16:00:002000-10-10 00:162000-10-10 00:16:00next Sunday2021-12-19n2021-12-17 19:44:25.868383YD.day16T.weekdayFridayT.day17T-10d2021-12-07T-1.5d2021-12-15 12:00:003M3 months3h+3M3 months, 3:00:002h2m2:02:007y6M5w4d3h2m1.1s7 years, 6 months, 39 days, 3:02:011M1d1 month, 1 day, 0:00:00-1y2M-1 year, -2 months0y2M2 months1y2M1 year, 2 months6y5M4d3h2m1s6 years, 5 months, 4 days, 3:02:0122h22m22:22:0022h+2m22:02:0012h:00 pm != 12h:00 amTrue2 < 1False2020 Jan 27 + 1y == 2021 Jan 27True1w7 days, 0:00:001970 Jan 1 - 3h in unix01d1m in hours24.021d+0h22m1 day, 0:22:001d1 day, 0:00:001d in seconds86400.001d in minutes1440.001d in hours24.001958-05-14 - 1958-05-16-2 days, 0:00:001957-12-26 22:22:22 - t-23367 days, 22:22:221957-12-26 - t-23367 days, 0:00:002014 Jan 13==2014 January 13True12h:00 AM != 12h:00 PMTrue1610494238.weekdayTuesday1610494238+4h.weekdayWednesday16104942382021-01-12 20:30:381-1-1-1-1-10:00:0022m:22 + 4h4:22:226pm18:00:006 pm + 1h19:00:006 pm18:00:002020-Jan-272020-01-2722:22:2222:22:2222:22:22s22:22:2222h:22:22s22:22:2222:22m:22s22:22:2222h:22m:22s22:22:2222h:22m:2222:22:2222h:2222:22:001996.04.281996-04-282014 January 132014-01-132014 Jan 132014-01-1311:20s PM00:11:2011h:20m pm23:20:0011h:20 am11:20:0011m:20 PM00:11:2011h:20 AM11:20:001-1-1 23:23S0001-01-01 00:23:231-1-1 23m:23S0001-01-01 00:23:231-1-1 23m:23s0001-01-01 00:23:231-1-1 23m:230001-01-01 00:23:231-1-1 23h:23m0001-01-01 23:23:001-1-1 23h:230001-01-01 23:23:001-1-1 23:23m0001-01-01 23:23:001-1-1 23:23:230001-01-01 23:23:23seconds until 2021 feb 14 12:00:00-26466270.992021 feb 14 12:00:002021-02-14 12:00:0010h30 + 14h1 day, 0:30:00n - 123418978 days, 22:23:57.2389471m in hours0.021 in unix108h308:30:00-1d.weekdayThursday(t + 180d)-180d == tTrue(n + 181d)-180d != nTrue(n + 180d)-180d == nTrue(T-1d).weekdayThursday