From a41345f75937cb1e204f0cd828d39cb02254caef Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 31 Jul 2024 23:00:35 -0400 Subject: Added Julian date logic --- README.md | 38 ++++++++++++++++++++++---------------- src/then.nim | 4 ++-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index cc742d9..fb59dca 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# then +# Then -Then is a minimalist plain text file calendar inspired by [When](https://www.lightandmatter.com/when/when.html). It has simple syntax optimized for the average scheduling case, but supports recurring cases more complex than most calendars. It optionally supports todo lists with deadlines as well. +Then is a minimalist, plain text, CLI calendar inspired by [When](https://www.lightandmatter.com/when/when.html). It has simple, concise syntax but supports recurring cases more complex than most calendars. It optionally supports todo lists with deadlines as well. -Then is a single binary with no dependencies for text nerds who want to manage events directly in their text editor rather than a TUI/GUI. You can columnize, group, sort, and archive events/todos in your .then file(s) to keep them neat, pretty, and human readable. +Then is a single binary with no dependencies for text nerds who primarily want to manage events directly in their text editor rather than a TUI/GUI. You can columnize, group, sort, and archive events/todos in your .then file(s) to keep them neat, pretty, and human readable. In terms of features and complexity, Then lies between [When](https://www.lightandmatter.com/when/when.html) and [Remind](https://dianne.skoll.ca/projects/remind/) but aims to be less verbose than either. @@ -137,7 +137,7 @@ Fri 05:00-06:00, Breakfast Fri 12pm-1pm, Lunch ``` -## Modified Julian Date (`J%x+y`) - Repeat every N days +## Modified Julian Day (`J%x+y`) - Repeat every N days Then supports using a Modified Julian Date as `J`. `J` is the number of days since midnight November 17, 1858. This can be used along with the modulo operator `%` to create complex recurring events. @@ -155,25 +155,31 @@ Jul 10-19 2025 J%3-2, This event repeats July 10, 13, 16, 19 Julian date modulus is definitely weird, but it's a concise way to express multiple uncommon recurring patterns without increasing program complexity and syntax vocabulary for features I virtually never use. Plus it's an homage to [When](https://www.lightandmatter.com/when/when.html), and I love When. +### Footnote for astronomers and time nerds + +Real Modified Julian Days tick over at Midnight UTC, so calculating a single MJD integer for a day in non-UTC time zone is *technically* incorrect. This parameter is more accurately "Modified Julian Day calculated as if your time zone was UTC". This distinction matters to absolutely no one since it's just a random consistent number that makes certain recurrences possible. + +This is similar to how When works, except When starts counting from JD 1, while Then starts (more correct-ish) from JD 0, so the J values are off by 1 between programs. + # Why would I use this? -Then was created to adapt existing CLI calendars to my personal workflow. Then is not only for the niche of people who use their terminal for scheduling, but for a sub-niche who prefer to edit a file over using a TUI which is why concise, legible syntax is so important. This is a very small group of people who virtually exclusively use [Remind](https://dianne.skoll.ca/projects/remind/). If you're happy with a web or phone calendar, Then probably won't change your mind. +Then was created to adapt existing CLI calendars to my personal workflow. Then is not only for the niche of people scheduling in their terminal, but for the sub-niche who prefer to edit a file over using a TUI. This is a small group of people who almost exclusively use [Remind](https://dianne.skoll.ca/projects/remind/). If you're happy with a web or phone calendar, Then probably won't change your mind. Then has a few benefits over similar text file calendars: 1. **Then has the most concise syntax**. It minimizes special characters and simplifies ranges. Remind is arguably nicer for complex recurring cases and supports more types of conditions, but I rarely need these: -**Then**: `1, Water bill`\ -**When**: `* * 1, Water bill`\ -**Remind**: `REM 1 MSG Water bill` + **Then**: `1, Water bill`\ + **When**: `* * 1, Water bill`\ + **Remind**: `REM 1 MSG Water bill` -**Then**: `Jul 1-7 2025, Vacation!`\ -**When**: `m=Jul & d>=1 & d<=7 & y=2025, Vacation!`\ -**Remind**: `REM Jul 1 2025 THROUGH Jul 7 2025 MSG Vacation!` + **Then**: `Jul 1-7 2025, Vacation!`\ + **When**: `m=Jul & d>=1 & d<=7 & y=2025, Vacation!`\ + **Remind**: `REM Jul 1 2025 THROUGH Jul 7 2025 MSG Vacation!` -**Then**: `Jul 10-19 2025 J%3-2`\ -**When**: `m=jul & d>=10 & d<=19 & y=2024 & !(j%3-2)`\ -**Remind**: `REM Jul 10 2025 *3 THROUGH Jul 19 2025` + **Then**: `Jul 10-19 2025 J%3-2`\ + **When**: `m=jul & d>=10 & d<=19 & y=2024 & !(j%3-2)`\ + **Remind**: `REM Jul 10 2025 *3 THROUGH Jul 19 2025` 2. Then *optionally* can use an archive file to treat events like todos @@ -186,14 +192,14 @@ Take the event "Change air filter", scheduled every 6 months. I might see that u If you're interested in other text file calendars, I highly recommend When or Remind. It's easy to get caught up yak shaving the maximalist Emacs, so Org Mode has a very different vibe and I don't find it nearly as productive. - [When](https://www.lightandmatter.com/when/when.html) - The simplest text file calendar that's flexible enough for real world use. -- [Remind](https://dianne.skoll.ca/projects/remind/) - The opposite: The most powerful, programmable calendar program ever made (CLI or otherwise) but simple cases are still concise. +- [Remind](https://dianne.skoll.ca/projects/remind/) - The most powerful, programmable calendar program ever made (CLI or otherwise) but simple cases are still concise. - [Better overview here.](https://blog.thechases.com/posts/remind/) - [Org Mode](https://orgmode.org) - An expansive productivity playground for text with agenda features, but also a time sink trap for tinkerers. ## See Also - [khal](https://github.com/pimutils/khal) - Similar CLI calendar, but stores calendars directly as .ics files. -- TUI calendar/productivity apps like [Calcurse](https://calcurse.org/), [calcure](https://github.com/anufrievroman/calcure), and maybe [Taskwarrior](https://taskwarrior.org/). +- TUI calendar/productivity apps like [calcure](https://github.com/anufrievroman/calcure), [Calcurse](https://calcurse.org/), and maybe [Taskwarrior](https://taskwarrior.org/). - [Emacs Diary](https://www.gnu.org/software/emacs/manual/html_node/emacs/Format-of-Diary-File.html) - A single agenda/diary file. - [Plain Text Personal Organizer](https://danlucraft.com/blog/2008/04/plain-text-organizer/) - [Calendar.txt](https://terokarvinen.com/2021/calendar-txt/) - A one-day per line text calendar idea inspired by [todo.txt](https://todotxt.org/). Very simple but high maintenence due to lack of repeating events, etc. diff --git a/src/then.nim b/src/then.nim index 5395ca4..cfd0b44 100644 --- a/src/then.nim +++ b/src/then.nim @@ -130,9 +130,9 @@ proc printCalendar() = printEvents(cal, curDay, "ddd yyyy MMM dd") proc main() = - var past: int = 1 + var past: int = 1 var future: int = 14 - var noArg: bool = true + var noArg: bool = true for kind, key, val in getopt(): case kind of cmdLongOption, cmdShortOption: -- cgit v1.2.3