WHEN(1)
๐ WHEN ๐
okay so bestie, welcome to When 1.1.45 โ this is the manual page for when, and honestly? it's giving โจminimalist personal calendarโจ energy and we're obsessed. buckle up ๐
๐ธ NAME ๐ธ
When โ a minimalistic personal calendar program. that's it, that's the whole name. iconic.
๐ฆ SYNOPSIS ๐ฆ
when
when [options] [commands]
the basic idea, bestie, is literally just to type when at the command line. that's the whole vibe. the first time you run the program, it will prompt you for some setup information (so it can get to know you ๐ซถ). to edit your calendar file in your favorite editor, do when e. the basic format of the calendar file is like this:
2003 feb 3 , Fly to Stockholm to accept Nobel Prize.
once you have a calendar file, running the program as plain old when from the command line will print out the things on your calendar for the next two weeks. no cap. ๐
๐ COMMANDS ๐
iโ print upcoming items on your calendar. (this is the default command, so like, if you don't say anything, this is what happens. main character energy fr fr.)cโ print calendars (grids like on a wall calendar, not showing items) for last month, this month, and next month. ๐eโ invoke your favorite editor to edit your calendar file. go off, edit queen. โ๏ธw,m,yโ print items for the coming week, month, or year, rather than for the default period of two weeks.jโ print the modified Julian day (useful for finding the time interval between two dates). math girlies rise ๐งฎdโ print nothing but the current date. minimal. clean. slay.
โจ OPTIONS โจ
all of the following options, except --help, can be set in the preferences file. true/false options can be set on the command line as --option or --nooption, and in the preferences file by setting the option to 0 or 1. so versatile ๐
--helpโ prints a brief help message. (this is the one that cannot live in the preferences file, iykyk.)--versionโ prints a brief message, including a statement of what version of the software it is. ๐ข--language=LANGโ set the language to LANG. see the section below on internationalization. this option is not normally needed, because the language is automatically detected. it just knows.--future=DAYSโ how many days into the future the report extends. default:14--past=DAYSโ how many days into the past the report extends. like the--futureoption,--pastis interpreted as an offset relative to the present date, so normally you would want this to be a negative value. default:-1--calendar=FILEโ your calendar file. the default is to use the file pointed to by your preferences file, which is set up the first time you run When. ๐๏ธ--editor=COMMANDโ command used to invoke your editor. default:"emacs -nw"โ example:when --editor="vim"--wrap=COLUMNSโ number of columns of text for the output (or0if you don't want wrapping at all). default:80--[no]wrap_autoโ attempt to detect the width of the terminal, and set the width of the output accordingly. this applies only if the output is a tty, and is subject to any maximum set by--wrap_max. overrides any value set by--wrap. default:no--wrap_max=COLUMNSโ maximum number of columns of text for the output (or-1if you don't want any maximum). useful in combination with--wrap_autoto preserve legibility on very large terminal windows. default:-1--rows=ROWSโ number of rows of text that will fit in the terminal window. when listing your calendar, output will be truncated to this length, unless that would result in listing less than three days into the future. this behavior is overridden (the maximum number of rows is set to infinity) if the--futureoption is given explicitly, or if themorycommand is used. to make this option have an effect, you will normally need to use--norows_autoas well. default:40--[no]rows_autoโ attempt to detect the height of the terminal, rather than using the value set in the--rowsoption. this applies only if the output is a tty. overrides any value set by--rows. default:yes--[no]headerโ print headers at the top of the output of thei,c,w,mandycommands. default:yes--[no]pagingโ when the output is longer than the value set byrowsorrows_auto, use a pager to display the output. (thePAGERandLESSenvironment variables are respected. ifPAGERisn't set, the default is"less.") default:yes--paging_less_optionsโ extra options if the pager is"less."default:"-rXFE"--[no]filter_accents_on_outputโ whether to change accented characters to unaccented ones. default:yes, unless the$TERMenvironment variable equals"mlterm"or"xterm".--[no]styled_outputโ if the output is a terminal, should we use ANSI terminal codes for styling? default:yes--[no]styled_output_if_not_ttyโ style the output even if it's not a terminal. default:no--calendar_today_style=STYLEโ says how to style today's date when doing the calendar (c) command. default:bold--items_today_style=STYLEโ says how to style the word ``today'' when doing the items (i) command. default:bold
the styling of output can be specified using the following keywords: bold, underlined, flashing. to change the color of the text, use these: fgblack, fgred, fggreen, fgyellow, fgblue, fgpurple, fgcyan, fgwhite. to change the background color, use similar keywords, but with bg instead of fg. example: when --calendar_today_style="bold,fgred,bgcyan" c ๐
--prefilterโ pipe the calendar file through a program before reading it. default:""--now="Y M D"โ pretend today is some other date. โฐ time travel bestie!!--[no]neighboring_monthsโ the default behavior of"when c"is to print out calendars for last month, this month, and next month. by choosing--noneighboring_months, you can avoid printing out months not included in the range set by--pastand--future.--[no]monday_firstโ start the week from Monday, rather than Sunday. default:no--[no]orthodox_easterโ calculate Easter according to the Orthodox Eastern Church's calendar. default:no--[no]ampmโ display the time of day using 12-hour time, rather than 24-hour time. also affects the parsing of input times. default:yes--auto_pm=xโ when times are input with hours that are less than x, and AM or PM is not explicitly specified, automatically assume that they are PM rather than AM. default:0--[no]literal_onlyโ only display items that are given as literal dates, e.g.,"2008 jul 4". don't display items that are defined by expressions, e.g., periodic items like"w=thu". default:no--test_expression--bare_version--make_filter_regex--test_accent_filtering
these options are used internally for building and testing. (not for us, bestie โ that's dev business ๐ ๏ธ)
๐ DESCRIPTION ๐
When is an extremely simple personal calendar program, aimed at the Unix geek who wants something minimalistic. it can keep track of things you need to do on particular dates. there are a lot of calendar and ``personal information manager'' programs out there, so what reasons are there to use When? bestie, let me tell you:
- it's a very short and simple program, so you can easily tinker with it yourself. When is about 2400 lines of Perl code (not counting documentation), whereas for example the command-line calendar Khal is 17,000, and Calcurse is 24,000. likeโฆ hello?? ๐
- it doesn't depend on any libraries, so it's easy to install. you should be able to install it on any system where Perl is available, even if you don't have privileges for installing libraries. ๐ซถ
- its file format is a simple text file, which you can edit in your favorite editor.
although When should run on virtually any operating system where Perl is available, in this document I'll assume you're running some flavor of Unix. ๐ง
๐ง INSTALLATION AND GETTING STARTED ๐ง
while logged in as root, execute the following command:
make install
run When for the first time using this command:
when
you'll be prompted for some information needed to set up your calendar file. and that's where the magic starts, bestie โจ
๐ USE ๐
Okay bestie, so if you run When again after that first setup run? It's gonna print one single line of text โ just the current date. That's it. No extra drama, because your calendar file is empty, so you literally have zero appointments coming up. ๐
Now you can start filling your calendar file with items. Each item is just a line of text that looks like this:
2003 feb 3 , Fly to Stockholm to accept Nobel Prize.
A super convenient way to edit your calendar file is with this command:
when e
This pops you straight into your favorite editor โ the one you picked when you ran When for the very first time. ๐
The date has to be in year-month-day format, but you can either spell the month or just give it as a number. (Month names are case-insensitive, and it doesn't matter if you represent February as F, Fe, Feb, Februa, or whatever โ it just has to be a unique match. You can give a trailing ., and it'll be ignored. In Czech, cer can be used as an abbreviation for Cerven, and cec for Cervenec.) Extra whitespace is ignored until you get into the actual text after the comma. Blank lines and lines beginning with a # sign are ignored.
If you now run When, it'll print out a list of all the items in your calendar file that fall within a certain time interval. (The interval starts from yesterday. When tries to pick the end of the time interval so its output fits on your terminal window, but it'll always be at least three days, and no more than two weeks in the future.) To see all your items for the next month, do when m, and similarly for a year, y, or a single week, w.
If you do when c, When prints out calendars for last month, this month, and next month. Iconic. โจ
You can combine these commands, bestie. For instance, when cw will print out calendars, and then show you your items for the next week. Slay.
For events that happen once a year โ birthdays, anniversaries, that kind of thing โ you can either use a * in place of the year,
* dec 25 , Christmas
or use a year with an asterisk:
1920* aug 29 , Charlie Parker turns \a, born in \y
In the second example, \a tells you how old Charlie Parker would be this year, and \y reproduces the year he was born. So the output would be:
today 2003 Aug 29 Charlie Parker turns 83, born in 1920
For things you have to do every week, you can use an expression of the form w=xxx, where xxx is the first few letters of the name of the day of the week in your language. (You have to supply enough letters to eliminate ambiguity, e.g., in English, w=th or w=tu, not just w=t.) Example:
w=sun , go to church, 10:00
You can actually do fancier tests than this too; for more info, see the section 'fancy tests' below. Here's how to set up some common holidays:
m=jan & w=mon & a=3 , Martin Luther King Day
* feb 14 , Valentine's Day
m=feb & w=mon & a=3 , Washington's Birthday observed
m=may & w=sun & a=2 , Mother's Day
m=may & w=mon & b=1 , Memorial Day
m=jun & w=sun & a=3 , Father's Day
* jul 4 , Independence Day
m=sep & w=mon & a=1 , Labor Day
m=oct & w=mon & a=2 , Columbus Day
m=nov & w=thu & a=4 , Thanksgiving (U.S.)
m=oct & w=mon & a=2 , Thanksgiving (Canada)
m=may & w=mon & (d>=18 & d<=24) , Victoria Day
* nov 11 , Armistice Day
e=47 , Mardi Gras
e=46 , Ash Wednesday
e=7 , Palm Sunday
e=0 , Easter Sunday
e=0-49 , Pentecost (49 days after easter)
In the U.S., when certain holidays fall on a weekend, federal workers โ and lots of private employees too โ get a Monday or Friday off. The full list is at http://www.opm.gov/operating_status_schedules/fedhol/2011.asp. If you want a reminder of both the holiday and the day you get off from work, here's how you'd set that up:
* jul 4 , Independence Day
m=jul & c=4 , Independence Day (observed as a federal holiday)
โจ COMMENTS โจ
Basically, a line beginning with the # character is taken as a comment, and is ignored. A line consisting only of whitespace characters is also ignored. Bye. ๐
๐ INTERNATIONALIZATION ๐
When has at least partial support for Czech, Danish, Dutch, English, French, German, Greek, Hungarian, Italian, Polish, Romanian, Spanish, Ukrainian and Portuguese. If When hasn't been translated into your language, or has only been partially translated, the text that hasn't been translated will be displayed in English. When should automatically detect what language you use (via your $LANG environment variable), and if When has been translated into that language, that's what you'll get โ When's output will be in your language, and When will also expect you to use that language in your calendar file for the names of the months and the days of the week. ๐
Your calendar file must be in UTF-8 (or ASCII, which is a subset of UTF-8). If your calendar file is in some other encoding, like ISO-8859, When will typically be able to detect that, and will refuse to read it. Command-line options can also contain UTF-8.
Some terminal emulators (aterm, ...) display accented characters as garbage, but others (mlterm, xterm...) can display them correctly. When checks the $TERM environment variable, and if it equals "mlterm" or "xterm", then accented characters will be displayed. Otherwise, they are filtered out of the output. You can override this by putting a line like
filter_accents_on_output = 0
or
filter_accents_on_output = 1
in your preferences file. I'd be interested in hearing from any users who can suggest a better mechanism for this than attempting to interpret the $TERM variable.
On input, accents are allowed, but not required. For example, in a French-language input file, the date 2005 Fev 17 could be given with an accented e or an unaccented one, and either will work. If an input month or day of the week doesn't match any of the ones for your language, then When will try to interpret it as English instead.
You can put a line like
language = fr
in your preferences file to set your language, or supply the --language option on the command line, but that's not necessary if your $LANG environment variable is set correctly.
๐ LOCATION AND FORMAT OF THE PREFERENCES FILE ๐
Most people will have their preferences file in ~/.when/preferences. But if you like keeping your home directory uncluttered with dotfiles, you can use one of these standard possibilities defined by the XDG standard. In decreasing order of priority: ${WHEN_CONFIG_HOME}/preferences, ${XDG_CONFIG_HOME}/when/preferences, $HOME/.config/when/preferences, and $HOME/.when/preferences. โจ
Each line consists of something like this:
variable = value
Whitespace is ignored everywhere except inside the value. Variable names are case-insensitive. Blank lines are ignored. Comments are allowed, prefaced by #.
๐ MORE EXAMPLES ๐
A super useful command to have your shell execute when you log in is this:
when --past=0 --future=1
To print out a calendar for a full year to come:
when --past=0 --future=365 c
๐ฆ POPPING UP YOUR CALENDAR WHEN YOU LOG IN ๐ฆ
Your calendar doesn't do you any good if you forget to look at it every day, bestie. An easy way to make it pop up when you log in is to make your .xsession or .xinitrc file look like this:
/usr/bin/when --past=0 --future=1 &>~/when.today
emacs -geometry 70x25 -bg bisque ~/when.today &
startkde
The .xsession file is used if you have a graphical login manager set up on your machine; the .xinitrc if you don't. In this example, the first line outputs your calendar to a file. The complete path to the When program is given, because your shell's path variable will not yet be properly initialized when this runs. The second line pops up a GUI emacs window, which is distinctively colored so it'll catch your eye. The last line starts your window manager โ KDE in this example. Whatever window manager you use, just make sure to retain the preexisting line in the file that starts it, and make sure that that line is the very last one in the file.
โฐ SORTING BY TIME OF DAY โฐ
If you want the various items on a single day to print out in a certain order, the simplest way is to put them in that order in the input file. That method won't work, though, when some items lie on dates determined by expressions rather than given explicitly. The most common reason you'd want to do this is that you have things to do at certain times during the day, and you want them sorted by time. In this situation, you can give a time at the beginning of the item's text, and When will recognize that and sort the items by time. Times can be in h:mm or hh:mm format. If --ampm is set, then an optional suffix a or p can be used for AM or PM, e.g., 9:30a for 9:30 AM. If you use AM/PM time, then you can also, e.g., set --auto_pm=9 so that hours less than 9 are automatically assumed to be PM. Here's an example:
2010 apr 25 , 7:00 dinner at the anarcho-syndicalist commune
w=sun , 10:00 church
April 25, 2010 is a Sunday, so on that date both of these items will be displayed. If --auto_pm is set to 8 or higher, then the 7:00 will automatically be interpreted as 7:00 PM, and the dinner date will be displayed below the morning church ceremony. Obsessed. ๐
โจ FANCY TESTS โจ
Okay bestie, so besides w (which we already talked about), there's a whole girl squad of other variables you can test:
wโ day of the weekmโ monthdโ day of the monthyโ yearjโ modified Julian day numberaโ 1 for the first 7 days of the month, 2 for the next 7, etc.bโ 1 for the last 7 days of the month, 2 for the previous 7, etc.cโ on Monday or Friday, equals the day of the month of the nearest weekend day; otherwise -1nโ number of days in this montheโ days until this year's (Western) Easterzโ day of the year (1 on New Year's day)
Months you can write as numbers, like m=2, or as names in your own language, like m=feb. And yes, you can use the logical operators & (and) and | (or). Periodt.
This next one reminds you to pay your employees on the first and fifteenth day of every month:
d=1 | d=15 , Pay employees.
And this one reminds you to rehearse with your band on the last Saturday of every month:
w=sat & b=1 , Rehearse with band.
Now watch this, because the following two lines:
* dec 25 , Christmas
m=dec & d=25 , Christmas
both do exactly the same thing ๐ โ but the first version is easier to understand and makes the program run faster. Why? Because when you do a test, When has to run through every single day in the range of dates you asked for and evaluate the test for each of those days. On my machine, if I print out a calendar for a whole year using a file with 10 simple tests in it, it takes a few seconds. So like, be mindful, bestie. Parentheses can be used, too.
Depending on your nationality and religion, you probably have a bunch of holidays that don't lie on fixed dates. In Christianity, many of these (the "movable feasts") are calculated relative to Easter Sunday, which is why the e variable is useful. iykyk ๐ฃ
There's a not operator, !:
w=fri & !(m=dec & d=25) , poker game
There's a modulo operator, %, and a subtraction operator, -. Using these, along with the j variable, it is just barely possible for When's little parser to perform the following feat:
!(j%14-1) , do something every other Wednesday
The logic behind this silly little piece of wizardry goes like this. First, we determine, using the command when j --now="2005 jan 26", that the first Wednesday on which we want to do this has a Julian day that equals 1, modulo 14. Then we write this expression so that if it's a Wednesday whose Julian day equals 1, modulo 14, the quantity in parentheses will be zero, and taking its logical negation will yield a true value. Not me doing math for fun ๐ญ she's literally iconic.
The operators' associativity and order of priority (from highest to lowest) is like this:
- left โ
% - left โ
- - left โ
< > <= >= - left โ
= != - right โ
! - left โ
& - left โ
|
๐ธ INCLUDING FILES ๐ธ
If your calendar file gets too large, you may prefer to split it up into smaller chunks โ perhaps one for birthdays, one for Tibetan holidays, etc. An easy way of accomplishing this is to install the program m4, put the line
prefilter = m4 -P
in your preferences file, and then put lines in your calendar file like this:
m4_include(/home/yourname/.when/birthdays)
Boom. Modular. Organized. We love a clean filesystem. ๐
๐ ENVIRONMENT ๐
$LANGโ to automatically detect the user's language$TERMโ to try to figure out if the terminal emulator can display accented characters
๐ฆ FILES ๐ฆ
$HOME/.when/calendarโ The default location for the user's calendar (pointed to by the preferences file)$HOME/.when/preferencesโ The user's preferences. (See above for alternative locations, which follow the XDG standard.)
๐ BUGS ๐
Okay so listen. The filename of the calendar file cannot have unicode in it. This is because perl's File::Glob::glob() function does not support unicode properly. See
http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/todo.pod
and
http://stackoverflow.com/questions/18436275/should-perls-fileglob-always-be-post-filtered-through-utf8decode
Not a vibe. Just a fact. Name your file in plain ASCII, bestie. ๐
โญ OTHER INFORMATION โญ
When's web page is at
http://www.lightandmatter.com/when/when.html ,
where you can always find the latest version of the software. Go get the fresh version, queen. ๐
๐ซถ AUTHOR ๐ซถ
When was written by Ben Crowell, http://www.lightandmatter.com/personal/. Dimiter Trendafilov wrote the new and improved parser for date expressions. Shoutout to the devs, fr fr. โจ
๐ COPYRIGHT AND LICENSE ๐
Copyright (C) 2003-2012 by Benjamin Crowell.
When is free software; you can redistribute it and/or modify it under the terms of the GPL, or, optionally, Perl's license.
And that's the whole page, bestie!! ๐ This one was version 1.1.45, dated 2022-12-09 โ so if you're reading a copy from the future, lowkey check the web page for something newer. Now go write yourself a calendar that slays. ๐๐
๐ฆ
๐ฆ where this page comes from
- debian bookworm: when 1.1.45-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: when 1.1.45-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: when 1.1.45-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: when 1.1.45-1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms