Dte: A language for expressing and calculating date and time
github.com
github.com
april+1M returns 2021-05-02
Well, months are the worst beasts of all of date parts. This tool doesn’t seem to handle them if not well then at least intuitive. Adding a month to april cannot result in may 2 in a sensible way.Some text editors have a similar feature for text lines. If you put your cursor at some column (including last one), then when moving up and down they try to retain that column if possible. E.g.
short lin<cursor>e</cursor>
longer line
shrt
When you move down, a cursor selects “n” and then “t”. When you move back up, it selects “n” again and “e” again.But if you place it at the end of line with ‘End’ key, it goes to the last char on every line when you move up/down. This is done by maintaining additional isAtEnd flag, until it is reset by a horizontal movement.
Month-to-day calculations should not add average (or now-related?) values to do a sensible thing. If you add month to a date (which for “april” I believe is “april 1”), it should just jump to “next-month 1”. If you add month to “march 31”, it should detect that it’s an end of month, and jump to “april 30” retaining isAtEnd until it’s reset by non-month operation, so +1M again gives “may 31”, and then -3M gives “feb 28(29)”. OR there should be a way to turn off “sticky end of month” mode. In no case that can result in “may 2”. Unless I’m missing something.
(I’ve made a similar library around ten years ago but never published it. It was designed for leasing contracts which love to use “a thursday before or including the fifth last day of a month next to the month in which insurance was paid” statements for their terms.
So long as you know what the other fields are and what their sizes are, you don’t really need separators.
It's pretty good at natural language interpretation of dates, and the basic "from today" calculations, but cool to also see here natural expressions to parse between dates.
3.weeks.ago.next_month.beginning_of_month.last_weekday.end_of_day
and it resolves to 2021-10-29 23:59:59.9999 as of today.{:ok, end_of_november} = 3 ¦> weeks ¦> ago ¦> next_month ¦> beginning_of_month ¦> last_weekday ¦> end_of_day
given the appropriate function declarations accepting at least either a number or a DateTime or some intermediate data structure as argument.
https://www.iso.org/obp/ui#iso:std:iso:8601:-1:ed-1:v1:en
https://www.compart.com/en/unicode/U+002D
https://www.compart.com/en/unicode/U+2212
Edit: parent comment now reflects this.
But the point of the standard isn't to provide something that everyone likes perfectly it's to provide a well defined format for exchanging datetimes instead of dealing with personal or cultural formats during interchange.
At least you can have a file named data-2021-11-13.csv.
(I guess they do it the other way around though: 13.11.2021.)
This is not only the German but most European way of writing date.
You can play with this in JS :)
const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
const options = { weekday: 'long', year: 'numeric', month: 'numeric', day: 'numeric' };
console.log(event.toLocaleDateString('de-DE', options));
console.log(event.toLocaleDateString('it-IT', options));
console.log(event.toLocaleDateString('fr-FR', options));
console.log(event.toLocaleDateString('hu-HU', options));
console.log(event.toLocaleDateString('sv-SE', options));
console.log(event.toLocaleDateString('es-ES', options));
console.log(event.toLocaleDateString('nl-NL', options));I suppose I should also be annoyed that I somehow never manage to type dates in the correct format if I need to write them by hand, but I'm not sure if I can blame ISO for that.
Note that these sign conventions are not universal: for example, POSIX has the reverse sign on timezone offsets because west positive was more convenient for american unix developers. There are similar oddities for longitude.
Yes, it's English month abbreviations but few people worldwide would not be able to take the obvious meaning.
(it's a MIL/NATO standard afaik, and has been in use for 50+ years)
(edit, timezones are single letter, e.g. Z for Zulu aka UTC)