af2date is a $\mathrm{\LaTeX}$ package that expands an Anno Fabri tag into its human-readable form, e.g., \af2date{0Boom} typesets Friday 18 September 2026, 16:25:54 CEST.
It does in a $\mathrm{\LaTeX}$ document what af 0Boom does in a terminal and {{afh}} does on this web. It also keeps the company of af2cal.
It was written with the kind contributions of Claude Opus 5.5 on 28 November (2026). Version 1.0.0.
AF tags are sprinkled in the document. They label the equations, the figures and the files names, e.g., \label{eq:0I8aJ}. They are also sprinkled everywhere else: emails, figures, code-versioning, Template:Y is not X and zeets, etc. I often need to refer to something external labelled by its AF tag in a $\mathrm{\TeX}$ document, in which case I use the AF tag itself. But when it comes to communicate with the outside word, something like Template:Ab may look weird (although they do pop up indeed, in filenames, typically). It is (still) more clear to have the traditional "Sunday 29 November 2026, 06:57:07 CET" form. \af2date{} does that.
It is written in $\mathrm{\TeX}$ itself, without calling af and without -shell-escape, so a document that uses it compiles wherever LaTeX does: on the arXiv, a journal, your computer, or overleaf if you use this type of things. It is declared in laussy.sty.
\usepackage{af2date}
...
\af2date{0Boom} % Friday 18 September 2026, 16:25:54 CEST
\af2date{0BoomH} % Friday 18 September 2026, 09:25:54 UTC-05
\newcommand\rdv{0Boom}
\af2date{\rdv} % the argument is expanded first
A five-character tag reads at Madrid's clock, CET or CEST as the season has it. A six-character one, made away from home, reads at the offset its last letter names—A = UTC−11 … Q = UTC+02 … m = UTC+14—and the zone is written the way af writes one that has no name: UTC+04, UTC-0330. The words are those of af -b, its third column, so the document and the terminal say the same thing the same way.
The command is fully expandable: it works in \edef, \typeout and \write, in a section title (the table of contents receives the date itself) and in hyperref's PDF bookmarks. Spaces around the tag are dropped. Something that is not a tag—\af2date{0Boo}, \af2date{0Boom5}—stops the run with '0Boo' is not an AF tag and is printed as it was given.
A $\mathrm{\TeX}$ command name is made of letters only, so \af2date is not one command but \af followed by the five characters 2date. The package defines \af with 2date as the delimiter of its argument—\def\af2date#1{…}, the very trick TeX's own help message mentions when such a delimiter is missed (\def\a1{...}). So \af is taken: alone, it stops with Use of \af doesn't match its definition. In expl3 code the same thing is \af_to_date:n.
It is the decoder of af, its back(), written over again in expl3. The first two characters are the era; the last three are undone through the six rounds of the Feistel network, each tweaked by the era, and out falls the second the tag stands for. Then the calendar: the day by Howard Hinnant's civil_from_days, the weekday from 1 January 1970 having been a Thursday, and Madrid's summer time by the EU rule—from 01:00 UTC on the last Sunday of March to 01:00 UTC on the last Sunday of October.
TeX's integers stop at 231, narrower than anything AF computes. The 32-bit words are kept as two 16-bit halves, products are taken a byte at a time so that none reaches 231, and the xor, which TeX does not have, is done bit by bit: the last bit of a xor b is the parity of a + b. The seconds are counted from 2026-08-17 00:00 UTC rather than from 1970, which keeps them under 231 to the end of AF's window, on 29 August 2055.
A tag costs about 5 milliseconds: nothing for a handful, five seconds for a table of a thousand.
af if its constants ever do: the round keys, the salt, the three multipliers, the epoch, the table of offsets.af asks the time-zone database for Madrid's offset; the package computes it from the EU rule. The two agree for as long as Europe keeps changing its clocks as it does now.af -b on 4581 tags—3000 at random, 30 for each of the 39 zone letters, the two ends of the window, a second either side of every change of the clocks from 2026 to 2055, the ends of the years and the 29ths of February: not one difference, under pdfLaTeX and LuaLaTeX (TeX Live 2025) and pdfLaTeX (TeX Live 2023).\expanded and expl3 in the kernel. The file goes in ~/texmf/tex/latex/af2date/, or next to the document.af2date.sty% af2date.sty -- v1.0.0 (28 Nov 2026) -- \af2date{TAG}: an AF tag read back as the moment it
% stands for, in the words of `af TAG' (its 3rd column):
% \af2date{0Boom} -> Friday 18 September 2026, 16:25:54 CEST
% \af2date{0BoomH} -> the same tag made away, at UTC-05: the clock there, then UTC-05
% A 5-character tag reads at Madrid's clock, CET or CEST; a 6-character one at the offset its
% last letter names (A = UTC-11 ... Q = UTC+02 ... m = UTC+14), written UTC+04, UTC-0330.
%
% THE NAME. A TeX command name is letters only, so \af2date is the command \af followed by
% the characters 2date: \af is defined with "2date" as the delimiter of its argument. It
% therefore takes \af for itself -- \af not followed by 2date stops with "Use of \af doesn't
% match its definition" -- and the package stops if something defined \af before it.
% \af_to_date:n is the same in expl3 code.
%
% FULLY EXPANDABLE: \edef, \typeout, \write, section titles (the .toc gets the date itself),
% hyperref's bookmarks. The argument is expanded first, so \af2date{\mytag} works; spaces
% around the tag are dropped. A bad tag is an error and prints as it was given.
%
% PURE TeX, any engine, no shell escape -- so it also runs on Overleaf, arXiv and at a
% journal, where ~/bin/AF cannot be called. The price: this is one more copy of AF's decoder
% (back() of ~/bin/AF, decode only) to keep in lockstep with it -- K, SALT, the three
% multipliers of f(), the epoch, OFF. TeX's integers stop at 2^31, so AF's 32-bit words are
% kept as two 16-bit halves {high}{low}, products are taken byte by byte, xor bit by bit,
% and the seconds are counted from 2026-08-17 00:00 UTC (day 20682, 79200 s before the epoch
% 1787004000), which stays below 2^31 to the end of AF's window (2055-08-29).
% Madrid's summer time is computed by the EU rule -- CEST from 01:00 UTC on the last Sunday
% of March to 01:00 UTC on the last Sunday of October -- where AF asks the tz database: the
% two agree as long as that rule stands.
% Checked against `af -b' on the tags listed in the session of 28 Nov 2026 (see the test
% note at the end of this file).
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesExplPackage {af2date} {2026/11/28} {1.0.0} {AF tag to its date and time}
% ---- 16-bit arithmetic ----
% a xor b, for a, b >= 0: bit by bit, the parity of a + b being the xor of their last bits
\cs_new:Npn \__af_xor:nn #1#2
{ \int_eval:n { 0 \__af_xor_loop:eee { \int_eval:n {#1} } { \int_eval:n {#2} } { 1 } } }
\cs_new:Npn \__af_xor_loop:nnn #1#2#3
{
\int_compare:nNnT { #1 + #2 } > { 0 }
{
+ #3 * \int_mod:nn { #1 + #2 } { 2 }
\__af_xor_loop:eee
{ \int_div_truncate:nn {#1} { 2 } }
{ \int_div_truncate:nn {#2} { 2 } }
{ \int_eval:n { 2 * #3 } }
}
}
\cs_generate_variant:Nn \__af_xor_loop:nnn { eee }
% a * b mod 2^16, for a, b < 2^16: b in bytes, so that no product reaches 2^31
\cs_new:Npn \__af_mul_lo:nn #1#2
{
\int_mod:nn
{
#1 * \int_mod:nn {#2} { 256 }
+ 256 * \int_mod:nn { #1 * \int_div_truncate:nn {#2} { 256 } } { 256 }
}
{ 65536 }
}
% \__af_mul:nnnnN {aH} {aL} {bH} {bL} \cont -> \cont {rH} {rL}, r = a * b mod 2^32
% (the high half: the carry out of aL * bL, plus aH * bL + aL * bH mod 2^16)
\cs_new:Npn \__af_mul:nnnnN #1#2#3#4#5
{
\use:e
{
\exp_not:N #5
{
\int_mod:nn
{
\int_div_truncate:nn
{
#2 * \int_mod:nn {#4} { 256 }
+ 256 * \int_mod:nn { #2 * \int_div_truncate:nn {#4} { 256 } } { 256 }
}
{ 65536 }
+ \int_div_truncate:nn { #2 * \int_div_truncate:nn {#4} { 256 } } { 256 }
+ \__af_mul_lo:nn {#1} {#4} + \__af_mul_lo:nn {#2} {#3}
}
{ 65536 }
}
{ \__af_mul_lo:nn {#2} {#4} }
}
}
\cs_generate_variant:Nn \__af_mul:nnnnN { ee }
% ---- f() of ~/bin/AF ----
% \__af_f:nnnnnn {x} {KH} {KL} {TH} {TL} {m} -> f(x) mod m, for the round key K and the
% era's tweak TW = hi * SALT; x < 2^16:
% h = (x ^ K ^ TW) * 0x9E3779B1; h = (h ^ h>>15) * 0x85EBCA6B; h = (h ^ h>>13) * 0xC2B2AE35;
% f = h ^ h>>16 (all mod 2^32)
\cs_new:Npn \__af_f:nnnnnn #1#2#3#4#5#6
{
\__af_mul:eennN
{ \__af_xor:nn {#2} {#4} }
{ \__af_xor:nn { \__af_xor:nn {#3} {#5} } {#1} }
{ 40503 } { 31153 } % 0x9E3779B1
\__af_f_ii:nnn {#6}
}
\cs_new:Npn \__af_f_ii:nnn #1#2#3
{
\__af_mul:eennN
{ \__af_xor:nn {#1} { \int_div_truncate:nn {#1} { 32768 } } }
{
\__af_xor:nn {#2}
{ 2 * \int_mod:nn {#1} { 32768 } + \int_div_truncate:nn {#2} { 32768 } }
}
{ 34283 } { 51819 } % 0x85EBCA6B
\__af_f_iii:nnn {#3}
}
\cs_new:Npn \__af_f_iii:nnn #1#2#3
{
\__af_mul:eennN
{ \__af_xor:nn {#1} { \int_div_truncate:nn {#1} { 8192 } } }
{
\__af_xor:nn {#2}
{ 8 * \int_mod:nn {#1} { 8192 } + \int_div_truncate:nn {#2} { 8192 } }
}
{ 49842 } { 44597 } % 0xC2B2AE35
\__af_f_iv:nnn {#3}
}
\cs_new:Npn \__af_f_iv:nnn #1#2#3
{
\int_mod:nn
{ \int_mod:nn {#1} {#3} * \int_mod:nn { 65536 } {#3} + \__af_xor:nn {#2} {#1} }
{#3}
}
% ---- the Feistel undone ----
% one round of back() (i = 4, 2, 0), K[i] and K[i+1] given as halves:
% \__af_round:nnnnnnnnn {K[i]H} {K[i]L} {K[i+1]H} {K[i+1]L} {TH} {TL} {cont} {L} {R}
% -> cont {L'} {R'}, R' = R - f(L, K[i+1]) mod 3844, L' = L - f(R', K[i]) mod 62
\cs_new:Npn \__af_round:nnnnnnnnn #1#2#3#4#5#6#7#8#9
{
\__af_round_ii:ennnnnn
{ \int_mod:nn { #9 + 3844 - \__af_f:nnnnnn {#8} {#3} {#4} {#5} {#6} { 3844 } } { 3844 } }
{#1} {#2} {#5} {#6} {#8} {#7}
}
\cs_new:Npn \__af_round_ii:nnnnnnn #1#2#3#4#5#6#7
{
\use:e
{
\exp_not:n {#7}
{ \int_mod:nn { #6 + 62 - \__af_f:nnnnnn {#1} {#2} {#3} {#4} {#5} { 62 } } { 62 } }
{#1}
}
}
\cs_generate_variant:Nn \__af_round_ii:nnnnnnn { e }
% \__af_decode:nnnn {hi} {L} {R} {zone}: hi = the era (chars 1-2), L and R = chars 3 and 4-5
% in base 62, zone = the index of the 6th letter in OFF, or -1 for a 5-character tag.
% TW = hi * SALT, SALT = 232959; K = 0x2f4b6c1d 0x7a19e3b5 0x5c83d271 0x1e6fa94b 0x3d5e8a17
% 0x64c2b90f. The second is hi * 238328 + L * 3844 + R after the epoch, + 79200 here.
\cs_new:Npn \__af_decode:nnnn #1#2#3#4
{
\__af_decode_ii:eennnn
{ \int_div_truncate:nn { #1 * 232959 } { 65536 } }
{ \int_mod:nn { #1 * 232959 } { 65536 } }
{#1} {#2} {#3} {#4}
}
\cs_new:Npn \__af_decode_ii:nnnnnn #1#2#3#4#5#6
{
\__af_round:nnnnnnnnn { 15710 } { 35351 } { 25794 } { 47375 } {#1} {#2} % K4, K5
{
\__af_round:nnnnnnnnn { 23683 } { 53873 } { 7791 } { 43339 } {#1} {#2} % K2, K3
{
\__af_round:nnnnnnnnn { 12107 } { 27677 } { 31257 } { 58293 } % K0, K1
{#1} {#2} { \__af_moment:nnnn {#3} {#6} }
}
}
{#4} {#5}
}
\cs_generate_variant:Nn \__af_decode_ii:nnnnnn { ee }
\cs_new:Npn \__af_moment:nnnn #1#2#3#4
{ \__af_when:en { \int_eval:n { #1 * 238328 + #3 * 3844 + #4 + 79200 } } {#2} }
% ---- the calendar ----
% S = seconds since 2026-08-17 00:00 UTC, zone as above
\clist_const:Nn \c__af_offsets_clist % OFF of ~/bin/AF, A to m
{
-39600, -36000, -34200, -32400, -28800, -25200, -21600, -18000, -14400, -12600,
-10800, -9000, -7200, -3600, 0, 3600, 7200, 10800, 12600, 14400, 16200, 18000, 19800,
20700, 21600, 23400, 25200, 28800, 31500, 32400, 34200, 36000, 37800, 39600, 43200,
45900, 46800, 49500, 50400
}
\clist_const:Nn \c__af_weekdays_clist
{ Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }
\clist_const:Nn \c__af_months_clist
{
January, February, March, April, May, June, July, August, September, October,
November, December
}
\cs_new:Npn \__af_when:nn #1#2
{
\int_compare:nNnTF {#2} < { 0 }
{
\__af_civil:eN { \int_eval:n { 20682 + \int_div_truncate:nn {#1} { 86400 } } }
\__af_home:nnnn {#1}
}
{
\__af_show:ee
{ \int_eval:n { #1 + \clist_item:Nn \c__af_offsets_clist { #2 + 1 } } }
{ \__af_zone:n { \clist_item:Nn \c__af_offsets_clist { #2 + 1 } } }
}
}
\cs_generate_variant:Nn \__af_when:nn { en }
% at home: the UTC year #1 (and month, day) of the second #4 decides CET or CEST
\cs_new:Npn \__af_home:nnnn #1#2#3#4
{
\int_compare:nNnTF {#4} < { \__af_switch:nn {#1} { 30 } }
{ \__af_show:en { \int_eval:n { #4 + 3600 } } { CET } }
{
\int_compare:nNnTF {#4} < { \__af_switch:nn {#1} { 244 } }
{ \__af_show:en { \int_eval:n { #4 + 7200 } } { CEST } }
{ \__af_show:en { \int_eval:n { #4 + 3600 } } { CET } }
}
}
% the second at which Madrid's clocks change in the year #1: 01:00 UTC on the last Sunday
% before 31 March (#2 = 30) or 31 October (#2 = 244), #2 being its day counted from 1 March
\cs_new:Npn \__af_switch:nn #1#2
{ \int_eval:n { ( \__af_lastsun:e { \__af_daynum:nn {#1} {#2} } - 20682 ) * 86400 + 3600 } }
\cs_new:Npn \__af_lastsun:n #1 { \int_eval:n { #1 - \int_mod:nn { #1 + 4 } { 7 } } }
\cs_generate_variant:Nn \__af_lastsun:n { e }
% days since 1970-01-01 of the day #2 (counted from 1 March) of the year #1: H. Hinnant's
% days_from_civil, for a month after February
\cs_new:Npn \__af_daynum:nn #1#2
{
\int_eval:n
{
146097 * \int_div_truncate:nn {#1} { 400 }
+ 365 * \int_mod:nn {#1} { 400 }
+ \int_div_truncate:nn { \int_mod:nn {#1} { 400 } } { 4 }
- \int_div_truncate:nn { \int_mod:nn {#1} { 400 } } { 100 }
+ #2 - 719468
}
}
% \__af_civil:nN {days since 1970-01-01} \cont -> \cont {y} {m} {d}: Hinnant's
% civil_from_days, for days >= -719468
\cs_new:Npn \__af_civil:nN #1#2
{
\__af_civil_ii:eeN
{ \int_div_truncate:nn { #1 + 719468 } { 146097 } }
{ \int_mod:nn { #1 + 719468 } { 146097 } }
#2
}
\cs_generate_variant:Nn \__af_civil:nN { e }
\cs_new:Npn \__af_civil_ii:nnN #1#2#3 % era, day of the era
{
\__af_civil_iii:ennN
{
\int_div_truncate:nn
{
#2 - \int_div_truncate:nn {#2} { 1460 } + \int_div_truncate:nn {#2} { 36524 }
- \int_div_truncate:nn {#2} { 146096 }
}
{ 365 }
}
{#1} {#2} #3
}
\cs_generate_variant:Nn \__af_civil_ii:nnN { ee }
\cs_new:Npn \__af_civil_iii:nnnN #1#2#3#4 % year of the era, era, day of the era
{
\__af_civil_iv:eeN
{
\int_eval:n
{ #3 - 365 * #1 - \int_div_truncate:nn {#1} { 4 } + \int_div_truncate:nn {#1} { 100 } }
}
{ \int_eval:n { #1 + 400 * #2 } }
#4
}
\cs_generate_variant:Nn \__af_civil_iii:nnnN { e }
\cs_new:Npn \__af_civil_iv:nnN #1#2#3 % day of the year from 1 March, year
{ \__af_civil_v:ennN { \int_div_truncate:nn { 5 * #1 + 2 } { 153 } } {#1} {#2} #3 }
\cs_generate_variant:Nn \__af_civil_iv:nnN { ee }
\cs_new:Npn \__af_civil_v:nnnN #1#2#3#4 % month from March, day, year
{
\use:e
{
\exp_not:N #4
{ \int_compare:nNnTF {#1} < { 10 } { #3 } { \int_eval:n { #3 + 1 } } }
{ \int_compare:nNnTF {#1} < { 10 } { \int_eval:n { #1 + 3 } } { \int_eval:n { #1 - 9 } } }
{ \int_eval:n { #2 - \int_div_truncate:nn { 153 * #1 + 2 } { 5 } + 1 } }
}
}
\cs_generate_variant:Nn \__af_civil_v:nnnN { e }
% UTC+04, UTC-0330, UTC+00: as `af' spells an offset that has no zone name
\cs_new:Npn \__af_zone:n #1
{
UTC \int_compare:nNnTF {#1} < { 0 } { - } { + }
\__af_two:n { \int_div_truncate:nn { \int_abs:n {#1} } { 3600 } }
\int_compare:nNnT { \int_mod:nn { \int_abs:n {#1} } { 3600 } } > { 0 }
{ \__af_two:n { \int_div_truncate:nn { \int_mod:nn { \int_abs:n {#1} } { 3600 } } { 60 } } }
}
\cs_new:Npn \__af_two:n #1 { \int_compare:nNnT {#1} < { 10 } { 0 } \int_eval:n {#1} }
% \__af_show:nn {wall-clock seconds since 2026-08-17 00:00} {zone}: the words
\cs_new:Npn \__af_show:nn #1#2
{
\__af_show_i:een
{ \int_eval:n { 20682 + \int_div_truncate:nn {#1} { 86400 } } }
{ \int_mod:nn {#1} { 86400 } }
{#2}
}
\cs_generate_variant:Nn \__af_show:nn { en , ee }
\cs_new:Npn \__af_show_i:nnn #1#2#3 { \__af_civil:nN {#1} \__af_show_ii:nnnnnn {#1} {#2} {#3} }
\cs_generate_variant:Nn \__af_show_i:nnn { een }
\cs_new:Npn \__af_show_ii:nnnnnn #1#2#3#4#5#6 % y m d, day number, second, zone
{
\clist_item:Nn \c__af_weekdays_clist { \int_mod:nn { #4 + 4 } { 7 } + 1 } ~
#3 ~ \clist_item:Nn \c__af_months_clist {#2} ~ #1 , ~
\__af_two:n { \int_div_truncate:nn {#5} { 3600 } } \c_colon_str
\__af_two:n { \int_mod:nn { \int_div_truncate:nn {#5} { 60 } } { 60 } } \c_colon_str
\__af_two:n { \int_mod:nn {#5} { 60 } } ~ #6
}
% ---- reading the tag ----
% the base-62 value of a character code (0-9 A-Z a-z), 99 for any other character
\cs_new:Npn \__af_value:n #1
{
\int_compare:nNnTF {#1} < { 48 } { 99 }
{
\int_compare:nNnTF {#1} < { 58 } { \int_eval:n { #1 - 48 } }
{
\int_compare:nNnTF {#1} < { 65 } { 99 }
{
\int_compare:nNnTF {#1} < { 91 } { \int_eval:n { #1 - 55 } }
{
\int_compare:nNnTF {#1} < { 97 } { 99 }
{ \int_compare:nNnTF {#1} < { 123 } { \int_eval:n { #1 - 61 } } { 99 } }
}
}
}
}
}
\cs_new:Npn \__af_code:n #1 { { \__af_value:n { `#1 } } }
\msg_new:nnn { af2date } { not-a-tag }
{ '#1'~is~not~an~AF~tag }
\cs_new:Npn \__af_error:n #1
{ \msg_expandable_error:nnn { af2date } { not-a-tag } {#1} #1 }
\cs_new:Npn \af_to_date:n #1
{ \__af_tag:e { \exp_args:Ne \tl_to_str:n {#1} } }
\cs_new:Npn \__af_tag:n #1 { \tl_trim_spaces_apply:nN {#1} \__af_tag_ii:n }
\cs_generate_variant:Nn \__af_tag:n { e }
\cs_new:Npn \__af_tag_ii:n #1
{ \__af_check:en { \str_map_function:nN {#1} \__af_code:n } {#1} }
% #1 = the values {v1}{v2}..., #2 = the tag as given
\cs_new:Npn \__af_check:nn #1#2
{
\int_case:nnF { \tl_count:n {#1} }
{
{ 5 } { \__af_check_v:nnnnnnn #1 { -1 } {#2} }
{ 6 } { \__af_check_vi:nnnnnnn #1 {#2} }
}
{ \__af_error:n {#2} }
}
\cs_generate_variant:Nn \__af_check:nn { en }
\cs_new:Npn \__af_check_v:nnnnnnn #1#2#3#4#5#6#7
{
\int_compare:nNnTF
{ \int_max:nn { \int_max:nn {#1} {#2} } { \int_max:nn { \int_max:nn {#3} {#4} } {#5} } }
< { 62 }
{ \__af_decode:eeen { \int_eval:n { 62 * #1 + #2 } } {#3} { \int_eval:n { 62 * #4 + #5 } } {#6} }
{ \__af_error:n {#7} }
}
\cs_generate_variant:Nn \__af_decode:nnnn { eeen }
\cs_new:Npn \__af_check_vi:nnnnnnn #1#2#3#4#5#6#7
{
\int_compare:nNnTF {#6} < { 10 } { \__af_error:n {#7} }
{
\int_compare:nNnTF {#6} > { 48 } { \__af_error:n {#7} }
{ \__af_check_v:nnnnnnn {#1} {#2} {#3} {#4} {#5} { \int_eval:n { #6 - 10 } } {#7} }
}
}
% ---- the command ----
\cs_new:Npn \af 2date #1 { \af_to_date:n {#1} }
% Test (28 Nov 2026): every tag of a list -- random 5- and 6-character ones, the window's two
% ends, both sides of every clock change 2026-2055, year ends, 29 February -- written out by
% \af_to_date:n and compared with the 3rd column of `af -b'.
\endinput