thanthese / bump-date

Complete and repeat dates easily.
1 stars 0 forks source link

Note: Deprecated

This project has been deprecated in favor of tickler-dates.

The behavior is almost-exactly-but-not-quite the same, though how things work behind the scenes is markedly different. The biggest difference is that the newer version is maintained.

Purpose

Command line tool for completing and repeating dates in a compact, human-readable format. Basically a big ball of "Do what I mean" for dates.

Usage

Operates on STDIN and STDOUT. To output the nearest Wednesday:

> echo "w" | node bump-date.js
15.01.14.w

Intended use is to pipe a line from a text editor through the utility and back into the active buffer, as with Emacs' shell-command-on-region or Vim's !!.

To run tests:

node bump-date.js --test

Plus one

Pass the --plus option to add one day to the passed-in date or --plus n to add n days. The date will be completed as usual and the given number of days added, but adds and repeats will be left untouched and unapplied. n can be negative.

Requirements

There aren't any installation instructions. It's just a single .js file -- download it and run it with node bump-date.js.

Tutorial

The date format is yy.mm.ddw, with weekdays Monday through Sunday written as: m, t, w, r, f, s, u. "Friday, April 12, 2013" would be written 13.04.12f. This format allows dates to be sorted numerically (sort -n).

If you give only part of the date the rest will be filled in. (These examples assume that today is March 30th, 2013.)

t                 => 13.04.02t
6                 => 13.04.06s
06                => 13.04.06s
03.30             => 14.03.30u
14.03.30          => 14.03.30u
14.03.30u         => 14.03.30u

An incorrect weekday will be corrected. Junk at the end of the line is ignored,

14.03.30u foo     => 14.03.30u foo

which lets you store a list of calendar items in a file, like this:

15.01.12m get groceries
15.01.13t make a million dollars
15.01.14w build a Scrooge McDuck pool

You can set a date relative to today with the +n add syntax, where n is a day, week, month, quarter, or year. If no unit is specified, day is assumed.

+4                => 13.04.03w
+4d               => 13.04.03w
+2w               => 13.04.13s
+1m               => 13.04.30t

Or set a date relative to a specific date.

13.03.30s+4d      => 13.04.03w

The -> syntax is similar to +, but it sticks around. This makes it easy to set up and manage recurring events.

13.04.01m->2d     => 13.04.03w->2d
13.04.01m->15     => 13.04.16t->15
13.03.30s->1w     => 13.04.06s->1w
13.03.01f->1m     => 13.04.01m->1m
13.03.30s->2y     => 15.03.30m->2y
->5d              => 13.04.04r->5d

The -> is only applied if (1) the date was complete (that is, it had a year, month, and day specified) or completely absent (not even a weekday), (2) there were no + adds, and (3) the --plus option was not used. The idea is that the date is "fixed" or "completed" before additional repetition rules are "applied" to it.

The :+ operator works almost the same way, but adds from today rather than the listed date. Use -> for events that always happen on the same day (Monday night bowling), and :+ for reminders you need n days after completing a task (even if you're 2 days late the house still doesn't need vacuuming again for another 4 days).

13.03.15f:+4d     => 13.04.03w:+4d

You can mix and match completion, adding, and a type of repetition.

31u+2w            => 13.04.14u
t+2d->2d          => 13.04.04r->2d
t+2w+1->2d        => 13.04.17w->2d
5+2w->2d          => 13.04.19f->2d
5+2w:+2d          => 13.04.19f:+1d

The last repeating operator, |+, is for those "2nd Sunday of the month" situations, like Mother's Day.

2nd Saturday of every month:

13.03.30s|+1m+2s  => 13.04.13s|+1m+2s

Last Saturday of every month:

13.03.30s|+1m-1s => 13.04.27s|+1m-1s

2nd sunday in may:

13.05.11s|+1y+2s  => 14.05.10s|+1y+2s

Some subtleties:

License

MIT