%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '32px'}}}%%
flowchart LR
A[Dec]-->B[date]-->C[time]-->D[snap]-->E[span]
click A "/dec"
click B "/dec/date"
click C "/dec/time"
click D "/dec/snap"
click E "/dec/span"
My website serves as a demonstration of both the Quarto publishing📤system and the Dec measurement📐system. I use several clever hacks to get Quarto to display all of the dates on my website in the Dec year+day format. Knowing the basics of the Dec calendar🗓️(Decalendar) will help you to understand the filter, include, and script articles in the Quarto section of my site.
Among its many features, Quarto offers support for the Observable data visualization system. Observable is my top choice for interactive graphics. We can interact with the two Observable calendar🗓️plots below⬇️using the adjacent Observable inputs. The scrubber🧽input is a great place to start because it cycles🔄through every value of the range🎚️inputs beneath it.
To activate the scrubber🧽input, press the Play▶️button above⬆️the range🎚️inputs. Upon activation, the red🟥box in each plot will move between the first and the last day of the Dec year. While it always begins with Day 0, the Dec year ends with either Day 364 or Day 365. To add or remove Day 365, use the toggle✅input labelled🏷️“Leap year” to the right of the Play▶️button.
The “Leap year” toggle✅input shifts 306 dates, Day 0 to Day 305, in the Gregorian calendar🗓️by one day, but does not change the order of any Dec dates, because Day 365 is the last day of Dec leap years and is always followed by Day 0 of the subsequent Dec year. The “Vertical layout” toggle✅input rotates the plots by a quarter turn, interchanging the x- and y-axes.
The axis labels🏷️of the plots imply that a dek and a day-of-dek (dod) are analogous to a week and a day-of-week (dow). Indeed, deks are groups of ten days that serve as the Dec analog of both weeks and months. With the exception of Day 365 in leap years, every year has the same deks and months, but not the same weeks, because the dow of the first day of the year varies.
The radio🔘input beneath the plots selects the dow for Day 306, the first day of the Gregorian calendar🗓️year. Changing the Day 306dow shifts every date in the Gregorian calendar🗓️by one to six days depending on the number of days that Week 0, the first week of the year, contributes to the year. In contrast, weeks have no effect on Decalendar.
Although weeks determine the shape of the Gregorian calendar🗓️plot, each of its cell values is a day-of-month (dom). To uniquely identify🪪a specific day in a year, a dom must be paired with the month to which it belongs. Both plots use three-letter abbreviations and the same color🎨scheme to label🏷️months, but are shifted in relation to each other by two months.
Day of year (doy)
A dek and dod can be combined into a single number called a day-of-year (doy). Every cell value in the Decalendar plot is a doy. The doy chosen by the range🎚️inputs to be highlighted with a red🟥background in the plots is . You can use the range🎚️inputs to convert a month and a dom into a doy. Try converting a special date such as your birthday🎂 or anniversary💍!
There are two range🎚️inputs labeled🏷️as “day of year” because every doy can be expressed as both a positive and a negative number. The typical range for doys is 0 to n-1, but negative doys typically range from -n to -1, where n is the number of days in the year, either 365 or 366. A doy outside these bounds represents a day in a previous or subsequent year.
The current doy can be expressed as or -. The difference between any positive doy and its negative equivalent is n: – - = . We obtain the current dek via the dek equation, = ⌊ ÷ 10⌋, and the current dod number via the dod equation: = mod 10. To combine a dek and dod, we multiply the dek by ten and add the dod: = × 10 + .
Unlike weeks in the Gregorian calendar🗓️, doys and deks do not need to continue in an infinite unbroken sequence. The last day of the year, Day -1, is always followed by Day 0, regardless of the last 4 or 5 days of Dek 36 that extend past the end of the year. If we want to track days seamlessly across years, we can use a continuous count of days called the day-of-era (doe).
Day of era (doe)
A doe is essentially a Julian day with a different epoch. We can convert a Julian day in a doe by subtracting 1721119.5 days to shift the epoch from -4713+268.5 to 0000+000.0. To turn a UNIX timestamp into a doe, we divide by 86400 to convert seconds to days and then add 719468.0 to account for the fact that the UNIX epoch is 1969+306.0.
Dec uses does for calculations, such as finding the POSIXzero-based dow of a given date. This year, the dow of Christmas🎄is according to the Dec dow equation: ( + 3) mod 7 = . In contrast to the dow, we can find the dod of Christmas🎄without any calculation because its dod, 9, is simply the last digit of the integer part of its doy: 299.
Christmas🎄is a fixed⚓️holiday because it occurs on the same doy every year. Unlike fixed⚓️holidays, Gregorian calendar🗓️floating🛟holidays happen on a different doy every year so that their dow can remain constant. Dec uses the dowdelta equation, wΔ = (wM – wS + 7) mod 7, to determine which of the seven possible floating🛟holiday dates corresponds to the given year.
In the dowdelta equation, wM is the minuenddow destination and wS is the subtrahenddow starting point. To get the doy of the first Dow 4 after Day 265, which is Thanksgiving🦃in the United States and Brazil, we plug 4 as wM and , the dow of Day 266 this year, as wS into the dowdelta equation, = (4 – + 7) mod 7, and then add wΔ to 266: = + 266.
Apart from the dow and dowdelta equations, the Thanksgiving🦃calculation above⬆️relies on the Dec doe equation, which is based on the days_from_civil algorithm created by Howard Hinnant and described in his manuscript entitled chrono-Compatible Low-Level Date Algorithms, to convert the cycle-of-era (coe), year-of-cycle (yoc), and doy of Day 266 into its doe:
The Dec date equations, the inverse🔁of the Dec doe equations above⬆️, are based on Howard Hinnant’s civil_from_days algorithm and are useful for obtaining Dec dates from does and doe analogs like Unix timestamps and Julian days. Besides the coe and yoc, the Dec date equations also use the day-of-cycle (doc) of a doe to produce the doe’s corresponding year and doy:
Dates generated by the Dec date equations are guaranteed to be in the standard year+day format. Therefore, we can standardize Dec dates by performing a round-trip date-to-doe-to-date conversion using the Dec doe and date equations consecutively. This allows Dec to handle Dec dates with a non-integer year and a day outside the typical range of 0 ≤ day ≤ 365.
Year of era (yoe)
A doe is essentially a Dec date with a year that is always equal to 0 and a day that is unbounded. Similarly, a Dec year-of-era (yoe) is basically a Dec with a non-integer year and a day permanently set to 0. Both does and yoes allow us to represent a date as a single number and obtain the difference between two dates, either in days (dM - dS) or years (yM – yS).
Compared to does, yoes are easier to turn into Dec dates. We can convert dates to yoes and vice versa with the Dec yoe equation: y = ⌊y⌋ + d ÷ n. In the Dec yoe equation, y is the yoe, ⌊y⌋ + d is the Dec date, ⌊y⌋ is the year, d is the doy, and n is the number of days in Year ⌊y⌋. The current yoe equation values are = + ÷ .
Dec dates do not include n, because it is not needed to specify a date, remains constant for 366, 1095, or 2920 days, has only 2 possible values: 366 if ⌊y⌋+1 is a Gregorian calendar🗓️leap year and 365 if ⌊y⌋+1 is a Gregorian calendar🗓️common year, and can be determined by applying the Gregorian calendar🗓️leap year rule to ⌊y⌋+1, as shown in the Dec year length equation:
\[\text{n}=\begin{cases}
366&{\begin{align}\text{if } (\lfloor \text{y}\rfloor+1)\text{ mod }\ \ \ \ 4=0\\
\href{https://en.wikipedia.org/wiki/Logical_conjunction}{\land}(\lfloor \text{y}\rfloor+1)\text{ mod }100\neq0\\
\href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}(\lfloor \text{y}\rfloor+1)\text{ mod }400=0\end{align}}\\\\
365&{\text{otherwise.}}\end{cases}\]
Apart from its role in the Dec date and doy equations, n is needed to convert between year+day and year-day Dec dates. The year-day version of the Dec yoe equation is y = ⌊y⌋ + 1 + (d – n) ÷ n. In essence, d-n is the number of days until the start of Year ⌊y⌋+1. The current year-day date, -, tells us that Year will begin in days.
The distinction between d and d-n can also be explained in terms of computer programming. If we think of years as arrays, d and d-n are like array indexes that can be used to identify array elements or combine them into groups via slicing. In this analogy, n is the number of elements in the array, d is a positive index, and d-n is a negative index.
The yoe equation can be rearranged into the Dec doy equation, d = ⌊ymod 1 × n⌋, where ymod 1 is the decimal part of y. The current doy equation values are = ⌊ × ⌋. In Dec, a doy by itself is a floating🛟date and a year+day date is a fixed⚓️date. Unlike fixed⚓️dates, floating🛟dates do not include a year and thus can apply to any year.
Fixed⚓️dates are unsimplified math expressions. Instead of simplifying a fixed⚓️date into a yoe, we can do the opposite and expand it to display additional information, such as the number of days in between it and another date. An expanded version of the current date, +299, can tell us that days Day 299🎄of this year.
In the example above⬆️, the minuend has been expanded into the subtrahend 299 and the difference as per the Dec minuend equation: minuend = subtrahend + difference. If we were preparing for a rocket🚀launch, the minuend would be the current time, the subtrahend would be the planned launch time, and the difference would be the “T-minus” countdown.
To see its minuend, subtrahend, and difference at the same time, we could rewrite the expanded date above⬆️as a Dec span🌈: +=+299. Unlike expanded dates, Dec spans🌈represent time intervals instead of individual dates and are structured like the minuend equation as opposed to a math expression that can be simplified to a yoe.
Whereas expanded dates have a set structure that does not change, Dec spans🌈can omit the subtrahend, +=, or the difference, +=+299. If the year is the same on both sides of the equals sign, it can be omitted from the minuend, =+299, or from the subtrahend along with the difference: +=299.
Dec spans🌈 can omit their entire left-hand side to indicate that the minuend is Day 0 of the given year. Similarly, an empty right-hand side means that the subtrahend is Day 0 of the subsequent year. Dec spans🌈with at least one year are called fixed⚓️spans🌈. In contrast, floating🛟spans🌈do not contain a year and thus can be reused♻️ every year.
Floating🛟dates and spans🌈are reusable♻️across all years, but the information displayed by expanded dates and spans🌈may not be. Information related to weeks is difficult to reuse♻️, because it takes 6 to 40 years for the pattern of dows in a year to repeat. At the price of reusability♻️, Dec can function without deks and use weeks instead.
Day of week (dow)
Even though Decalendar functions best with deks, Dec dates can display POSIX zero-baseddows. Instead of the current Dec date, +, the navigation bar (navbar) of my site displays the current Dec dow date, +, by splitting the current doy, , into the doy of the first day of the current week (Dow 0doy), , and the current POSIX dow: .
Instead of the doyd, Dec dow dates display d-w+w, where d-w is the Dow 0doy and w is the dow associated with d. We evaluate the subtraction, d-w, to obtain the Dow 0doy, but leave the addition unsimplified so we can see w. Dec dow dates supply all of the information needed to identify specific dates and coordinate schedules based on deks or weeks.
The dow equation, dow = (doe + 3) mod 7, is derived from Howard Hinnant’s weekday_from_days algorithm. The Dec epoch dow is 3 = (0 + 3) mod 7. The UNIX epoch dow is 4 = (719468 + 3) mod 7. Depending on how mod is defined, a negative doe could yield a negative dow: -1 = (-60 + 3) mod 7. To convert a negative dow into a positive dow, we add 7.
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
0
1
2
3
4
5
6
-7
-6
-5
-4
-3
-2
-1
Week of year (woy)
Dec dow dates can be further expanded to include Dec week-of-year (woy) numbers: +7×+. The current woy, , is the sum of the Dow 0doy, , and the first dow of the year (Day 0dow), , divided by 7: = ( + ) ÷ 7. The current Dec floating🛟woy date, 7×+, is equal to the sum of the current doy and the Day 0dow: 7 × + = + .
To create a Dec woy date, we need two types of Dec expansion: minuend and dividend expansion. First, we turn the minuend d into the subtrahend d-w and the difference w. Then, we use the dividend equation, dividend = divisor × quotient, to convert the dividend d-w+w0 into the divisor 7 and the quotient W, where W is the woy and w0 is the Day 0dow.
Essentially, Dec woy dates turn d-w into 7×W+w-w0. Typically, only 7×W+w is displayed, because w0 is not necessary to identify a date and can be calculated from a given y by flooring it, turning it into a doe, and passing it into the dow equation. Dec woy dates obfuscate🫣d much more than dow dates, but may be useful for week-based accounting🧾.
Day of dek (dod)
While weeks are not evenly divisible by two, a dek can be cut✂️into two equal halves called pentadays (pents). The Mermaid flowcharts below⬇️show Schedule 3, the recommended dekly schedule of work and rest day. Schedule 3 can be short for Schedule 1+3+1, if you prefer the zero-based top flowchart, or Schedule 3+2, if you favor the one-based bottom flowchart.
%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '29px'}}}%%
flowchart TB
A[0]-->B[1]-->C[2]-->D[3]-->E[4]
F[5]-->G[6]-->H[7]-->I[8]-->J[9]
subgraph workdays[work days]
B
C
G
H
D
I
end
subgraph restdays[rest days]
A
F
E
J
workdays
end
style restdays color:transparent;
%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '29px'}}}%%
flowchart TB
B[1]-->C[2]-->D[3]-->E[4]-->F[5]
G[6]-->H[7]-->I[8]-->J[9]-->A[10]
subgraph workdays[work days]
B
C
G
H
D
I
end
subgraph restdays[rest days]
A
F
E
J
workdays
end
style restdays color:transparent;
Both flowcharts use dod numbers, but the bottom one starts from Dod 1 instead of Dod 0 and refers to Dod 0 as Dod 10. Like the dods in the flowcharts above⬆️, the doys in the tables below⬇️are arranged in both a zero-based (top) and a one-based (bottom) manner. The tables visualize the seamless transition between a common year and the subsequent year.
Rest
Work
Work
Work
Rest
360
361
362
363
364
0
1
2
3
4
Work
Work
Work
Rest
Rest
361
362
363
364
0
1
2
3
4
5
After 4 or 8 years of consecutive pents, the Schedule 3 pattern shown in the flowcharts and tables above⬆️is interrupted by 3 consecutive rest days during the transition from a leap year. This interruption is represented by 4 empty cells in the middle row of the two tables below⬇️. The middle row contains only one day: Day 365 in the top table and Day 0 in bottom one.
Rest
Work
Work
Work
Rest
360
361
362
363
364
365
0
1
2
3
4
Work
Work
Work
Rest
Rest
361
362
363
364
365
0
1
2
3
4
5
The last pentaday (pent) in common years is Pent 72. Day 365 is the only day in Pent 73. Day 0 is the first day of Pent 0, the first pent of the year. To get the current pent number, , we double the current dek number, , and then add 1 if the current dod number, , is greater than 4. To avoid off-by-one errors, pent, dek, dod, and dow numbers are always zero-based in Dec.
Other than pent numbers, a pent can also be expressed as a span🌈. Pent 72 can be represented as 360=365-5, 360=-5, or 360=365. In addition to omitting the subtrahend or the difference, we can make the subtrahend precede the minuend to indicate that we want to start from the latest day and work backwards: 365=360+5, 365=360, or 365=+5.
Spans🌈can also represent groups of non-consecutive days. All of the Schedule 3work days in a year can be expressed as 1=4=:5. In this span🌈, we start with Days 1, 2, and 3 and then include every day that is a multiple of 5 days away from one of the starting days. The number preceded by a colon is called a step and determines which days we want to include.
Schedule 3 is one of six dekly schedules that allow us to organize work and rest days into five homogeneous columns like in the tables and flowcharts above⬆️. These schedules are like the gears⚙️of a 5-speedmanual transmission in a car. The approximate speed ranges for the five gears⚙️are <5, 5 to 10, 10 to 15, 15 to 20, and ≥20 kilometers per centiday.
In this analogy, Neutral (N), 1st, 2nd, 3rd, 4th, and 5th gear⚙️are Schedules 0, 1, 2, 3, 4, and 5, respectively. To complete the gearshift analogy, Reverse (R) would be a time machine that takes us to the past. As our driving speed changes, we would shift up to a higher gear⚙️or shift down to a lower gear⚙️. Similarly, we can switch between the six dekly schedules as needed.
The names of the dekly schedules are derived from their respective numbers of work days per pent. The total🧮number of work days per year provided by Schedules 0, 1, 2, 3, 4, and 5 are 0, 73, 146, 219, 292, and 365, respectively. In general, Schedule 3 should be the default and Schedule 5 should only be used temporarily during crises‼️and emergencies🚨.
In addition to switching between schedules, we can also mix them to create hybrid schedules. Schedule 34 mixes Schedules 3 and 4 to obtain an annual total🧮of 255 work days without modifying the transition between years shown in the tables above⬆️. This annual total🧮is about 1 pent less than the 260 to 262 work days that we get annually from a 5-day workweek.
Unlike weekly schedules, Schedules 3 and 34 provide a consistent🎯number of work days every year. While Days 364, 365, and 0 can be work or rest days in the Gregorian calendar🗓️, these days are always rest days if we follow Schedules 3 or 34. Therefore, Schedules 3 and 34 do not require any holidays to smooth the transition between years.
There are 11 United States Federal holidays. Federal holidays that fall on a Gregorian calendar🗓️rest day, Dow 0 or Dow 6, are observed on the nearest Gregorian calendar🗓️work day: Dow 1 or Dow 5. To apply this rule to Schedule 3, we would observe the Day 110⛓️💥, 125🎆, 255🫡, and 299🎄holidays on Days 111⛓️💥, 126🎆, 256🫡, and 298🎄, respectively.
With dekly schedules, we can determine whether any date falls on a work or a rest day with just a glance. Counterintuitively, dekly schedules can be based on months instead of deks. Month-based dekly schedules distinguish between work and rest days based on the last digit of doms. The drawback of month-based schedules is that doms reset twelve times every year.
The month-based Schedules 3 and 34 have 223 and 258 work days per year, respectively, but will require at least one holiday to avoid six consecutive work days during the transition from a Dec common year. The best time to switch from a weekly to a dekly schedule may be from Day 31 to 93 when the original and month-based versions of Schedules 3 and 34 are identical.
Day of month (dom)
Dec dates can be expanded to display Dec month and POSIX dom numbers. The current Dec dom date is ++. Dec month numbers are the last doy of the previous month because POSIX doms are one-based. For zero-based doms, Dec represents each month with its first doy: ++. This way, Dec can support both zero- and one-based doms.
Dec dom dates replace the doyd from Dec dates with d-m+m. We evaluate the subtraction to get d-m, the Dec month number, but not the addition, so we can see m, the dom. If we combine the dom and dow patterns above⬆️, we can create hybrid dom+dow Dec dates: +++, where is d-m-w, the doy of the last Dow 0 before the beginning of the month.
We can obtain Dec month numbers using only a pair of hands🤲by counting index☝️and ring💍fingers as 30 days and other fingers as 31 days. For zero-based doms, we start counting from 0. For one-based doms, we start counting from -1, as shown in the image below⬇️. To spread 12 months across 10 fingers, the first and last fingers each represent 2 months.
The finger🖐mnemonic described above⬆️is similar to the knuckle👊and musical keyboard🎹mnemonics. These mnemonics attempt to make sense of the irregular pattern of month lengths in the Gregorian calendar🗓️. As opposed to months, we do not need mnemonics, tables, or mental calculations to use deks, because all of the required information is plainly visible in the doy.
Month of year (moy)
To convert doys to or from POSIX month and dom numbers, we can use the month-of-year (moy) equations from the civil_from_days and days_from_civil algorithms. Unlike POSIX month numbers, moys are zero-based and start from Moy 0 instead of Moy 10. As shown in the first moy equation below⬇️, we can obtain a moy from a doy or a POSIX month number.
A moy and its equivalent POSIX month number differ by 9 in Moy10 or 11 and -3 in any other moy because the Dec epoch, 0000+000, is 2 months later than the Gregorian calendar🗓️epoch: -0001+306. To convert years, we add 1 to Dec years and subtract 1 from Gregorian calendar🗓️years if the doy is greater than 305, the moy is greater than 9, or the month is less than 3:
This article describes Dec and how it can interoperate with the Gregorian calendar🗓️by minuend expanding Dec dates into dom and dow dates or dividend expanding dow dates into woy dates. On its own, Dec minuend expands dates into span🌈equivalents, but has no use for dividend expansion, because doys display deks and dods without any expansion.
The flowchart below⬇️visualizes the conversion of the UNIX epoch Dec date 1969+306 into a Gregorian calendar🗓️year, month, dom and dow. To obtain its associated dow, we first need to convert a Dec date into a doe. Outside of its interoperability with the Gregorian calendar🗓️, Dec converts dates into does to find the number of days in between two dates.
%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '20px'}}}%%
flowchart LR
L~~~Y
L-->Y
L-->D
L-->E
R-->Y
M-->R[ ]:::empty
D-->A
D~~~B[ ]:::empty
A-->G
G-->R
Y~~~L[ ]:::empty
Y---A[ ]:::empty
Y~~~A
B-->M
B~~~N
B-->N
B-->D
B~~~D
N~~~B
E-->W
subgraph decdate[Decalendar]
Y[year<br>1969]
D[doy<br>306]
E[doe<br>719468]
end
subgraph gregdate[Gregorian calendar]
W[dow<br>4]
G[year<br>1970]
M[month<br>1]
N[dom<br>1]
end
classDef empty width:0px;
click E "#doe"
click W "#dow"
click Y "#yoe"
click D "#doy"
click G "#yoe"
click M "#moy"
click N "#dom"
For simplicity, the flowchart above⬆️does not show conversion byproducts, such as the coe, yoc, and doc generated during Dec doe to date conversion or the moy that we need in order to split a doy into a month and a dom or combine a month and a dom into a doy. The arrows in the flowchart represent equations adapted from chrono-Compatible Low-Level Date Algorithms.
Instead of converting Dec dates, we can expand them to view the information we need as part of the math-inspired notation of Dec. At its heart❤️, Dec is a simple system that uses only years and days for time measurement. Thanks to Dec expansion, Dec can work with other units. In this way, Dec expansion bridges the gap between the Dec and Gregorian calendars🗓️.
Next
After reading this article, you should be able to understand the examples in my filter, include, and script articles, but you may want to start with my Quarto article. To see the full extent of the benefits that Dec provides, I recommend that you continue through the Dec section of my site to the time⏳, snap🫰, and span🌈articles. Dec has a lot more to offer than just dates!
%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '32px'}}}%%
flowchart LR
A[Dec]-->B[date]-->C[time]-->D[snap]-->E[span]
click A "/dec"
click B "/dec/date"
click C "/dec/time"
click D "/dec/snap"
click E "/dec/span"
In addition my Dec and Quarto articles, many other articles on my site discuss Dec. Notably, my Jupyter article compares the code underlying Dec in several programming languages, my Reveal article features a presentation on Dec time measurement, and my Observable article describes how I demonstrate Dec in action with interactive and animated visualizations.
Cite
Thank you for your interest in Dec. You will find citation information for this article below⬇️. Please note that the original source of the algorithms underlying the conversion of Dec year+day dates and does is Hinnant, Howard. 2021+184. “chrono-Compatible Low-Level Date Algorithms.” +. https://howardhinnant.github.io/date_algorithms.html.
---title: Dec Dateauthor: - name: Martin Laptev url: https://maptv.github.ioimage: /asset/cal16.svgdescription: > Introducing the Dec calendar (Decalendar), which displays dates in years and days using math notation without the need for months or weeks.citation: url: https://maptv.github.io/dec/datealiases: - /dec/date - /date - /d/dlicense: CC BY-SAlightbox: falsetoc: truetoc-depth: 4bread-crumbs: falseformat: html: grid: body-width: 900px shift-heading-level-by: 3 include-after-body: - ../../asset/cite.html - ../../asset/style.html - ../../asset/stamp.html - ../../asset/tooltip.html commonmark: defaultfilters: - ../../asset/date.lua---```{mermaid}%%| label: datenav%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '32px'}}}%%flowchart LR A[Dec]-->B[date]-->C[time]-->D[snap]-->E[span] click A "/dec" click B "/dec/date" click C "/dec/time" click D "/dec/snap" click E "/dec/span"```My website serves as a demonstration of both the [Quarto](https://quarto.org) publishing📤system and the [Dec](/dec) measurement📐system. I use several clever hacks to get Quarto to display all of the dates on my website in the Dec [year]{.yellow}+[day]{.cyan} format. Knowing the basics of the Dec calendar🗓️(Decalendar) will help you to understand the [filter](https://quarto.org/docs/extensions/filters.html), [include](https://quarto.org/docs/output-formats/html-basics.html#includes), and [script](https://quarto.org/docs/projects/scripts.html) articles in the [Quarto section](/quarto) of my site.Among its many features, Quarto offers support for the [Observable](https://observablehq.com/) data visualization system. Observable is my top choice for interactive graphics. We can interact with the two Observable [calendar🗓️plots](https://observablehq.com/@observablehq/plot-calendar)below⬇️using the adjacent Observable [inputs](https://observablehq.com/documentation/inputs/overview). The [scrubber](https://observablehq.com/@mbostock/scrubber)🧽input is a great place to start because it cycles🔄through every value of the [range](https://observablehq.com/@observablehq/input-range)🎚️inputs beneath it.To activate the scrubber🧽input, press the Play▶️button above⬆️the range🎚️inputs. Upon activation, the red🟥box in each plot will move betweenthe first and the last day of the Dec [year]{.yellow}. While it always begins with [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"}, the Dec [year]{.yellow} ends with either [Day 364]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 28"} or [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"}. To add or remove [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"}, use the [toggle](https://observablehq.com/@observablehq/input-toggle)✅input labelled🏷️"Leap year" to the right of the Play▶️button.The "Leap year" toggle✅input shifts 306 dates, [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} to [Day 305]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="December 31"}, in the Gregorian calendar🗓️by one day, but does not change the order of any Dec dates, because [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"} is the last day of Dec leap [years]{.yellow} and is always followed by [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} of the subsequent Dec [year]{.yellow}. The "Vertical layout" toggle✅input rotates the plots by a quarter turn, interchanging the x- and y-axes.The axis labels🏷️of the plots imply that a [dek]{.cyan} and a [day-of-dek]{.cyan} ([dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"}) are analogous to a [week]{.darkgreen} and a [day-of-week]{.lightgreen} ([dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}). Indeed, [deks]{.cyan} are groups of ten days that serve as the Dec analog of both [weeks]{.darkgreen} and [months]{.azul}. With the exception of [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"} in leap [years]{.yellow}, every [year]{.yellow} has the same [deks]{.cyan} and [months]{.azul}, but not the same [weeks]{.darkgreen}, because the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} of the first day of the [year]{.yellow} varies.```{ojs}//| echo: false//| label: leapscrubvertviewof leapscrub = Inputs.form([Scrubber(numbers, {autoplay:false,alternate:true,delay:86.4,loopDelay:864,format: y =>"",inputStyle:"display:none;"}), Inputs.toggle({label:"Leap year",value:false}), Inputs.toggle({label:"Vertical layout",value:false}),])``````{ojs}//| echo: falseviewof dotyInput = Inputs.range([0,364+ leapInput], {value:306,step:1,label:"Day of year"});viewof monthInput =transformInput( Inputs.range([1,12], {step:1,label:"Month"}), {bind: viewof dotyInput,transform: doty2month,invert: month2doty});viewof dotyInput1 =transformInput( Inputs.range([-365- leapInput,-1], {step:1,label:"Day of year"}), {bind: viewof dotyInput,transform: subN,invert: addN});viewof dotmInput =transformInput( Inputs.range([1,31], {step:1,label:"Day of month"}), {bind: viewof dotyInput,transform: doty2dotm,invert: (x =>Math.floor(( 153* ( viewof monthInput.value>2? viewof monthInput.value-3: viewof monthInput.value+9) +2 ) /5+ x -1))});```::: {.column-page}```{ojs}//| echo: falsedecPlot = turnInput ? Plot.plot({title:"Decalendar",padding:0,width:480,height:980,className:"leftplot",marginTop:-3,marginRight:31,marginBottom:35,x: {tickSize:0,label:"Day of dek ",domain: [0,1,2,3,4,5,6,7,8,9],ticks: [0,1,2,3,4,5,6,7,8,9],tickPadding:-9,labelOffset:24, },y: {interval:1,ticks:18,label:"Dek",type:"band",tickSize:0,tickPadding:-2,labelOffset:40,labelArrow:false},//fx: {tickFormat: ""},style: { fontSize:"21px" },color: {range: d3.schemePastel1.concat(d3.schemePastel2.slice(4,7)).concat(d3.schemeSet1[0]),domain: months.concat("selected"),className:"cal", },marks: [ Plot.cell(dates, {y: (d, i) =>Math.floor(i /10),x: (d, i) => i %10,//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"selected": months[d.getUTCMonth()],stroke: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"darkorange":"none",strokeWidth:3,inset:0.5, }), Plot.text(dates, {y: (d, i) =>Math.floor(i /10),text: d => d.getUTCDate() ===11? months[d.getUTCMonth()].slice(0,3) :"",frameAnchor:"right",dx:32,monospace:true,fontSize:"18px"}), Plot.text(dates, {y: (d, i) =>Math.floor(i /10),x: (d, i) => i %10,//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"white":"black",//stroke: "white",text: (d, i) =>String(i),//.padStart(3, "0").slice(1),monospace:true,fontSize:"16px"}) ] }) : Plot.plot({title:"Decalendar",padding:0,width:1280,height:280,className:"topplot",marginTop:-3,marginLeft:31,marginBottom:35,y: {tickSize:0,label:"Day of dek ",domain: [-1,0,1,2,3,4,5,6,7,8,9],ticks: [0,1,2,3,4,5,6,7,8,9],tickPadding:-4,labelOffset:28, },x: {interval:1,ticks:18,label:"Dek",type:"band",tickSize:0,tickPadding:-2,labelOffset:32,labelArrow:false},style: { fontSize:"21px" },color: {range: d3.schemePastel1.concat(d3.schemePastel2.slice(4,7)).concat(d3.schemeSet1[0]),domain: months.concat("selected"),className:"cal", },marks: [ Plot.cell(dates, {x: (d, i) =>Math.floor(i /10),y: (d, i) => i %10,//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"selected": months[d.getUTCMonth()],stroke: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"darkorange":"none",strokeWidth:3,inset:0.5, }), Plot.text(dates, {x: (d, i) =>Math.floor(i /10),y: (d, i) => i %10,//fx: d => d.getUTCFullYear(),text: d => d.getUTCDate() ===11? months[d.getUTCMonth()].slice(0,3) :"",y:-1,frameAnchor:"left",dy:-1,monospace:true,fontSize:"18px"}), Plot.text(dates, {x: (d, i) =>Math.floor(i /10),y: (d, i) => i %10,//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"white":"black",//stroke: "white",text: (d, i) =>String(i),//.padStart(3, "0").slice(1),monospace:true,fontSize:"16px"}) ]})``````{ojs}//| echo: falsecalPlot = turnInput ? Plot.plot({title:"Gregorian calendar",padding:0,width:280,height:980,className:"rightplot",marginTop:10,marginBottom:30,marginRight:42,x: {tickFormat: Plot.formatWeekday("en","narrow"),tickSize:0,domain: [-1,0,1,2,3,4,5,6],ticks: [0,1,2,3,4,5,6],tickPadding:2, },y: {interval:1,ticks:26,label:"Week",type:"band",tickSize:0,tickPadding:-26,labelOffset:16,labelArrow:false},style: { fontSize:"21px" },color: {range: d3.schemePastel1.concat(d3.schemePastel2.slice(4,7)).concat(d3.schemeSet1[0]),domain: months.concat("selected"),className:"cal", },marks: [ Plot.cell(datesCal, {y: d => d3.utcWeek.count(d3.utcYear(d), d),x: d => d.getUTCDay(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"selected": months[d.getUTCMonth()],stroke: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"darkorange":"none",strokeWidth:3,inset:.5, }), Plot.text(datesCal, {y: d => d3.utcWeek.count(d3.utcYear(d), d),text: d => d.getUTCDate() ===9? months[d.getUTCMonth()].slice(0,3) :"",frameAnchor:"right",dx:32,monospace:true,fontSize:"18px"}), Plot.text(datesCal, {y: d => d3.utcWeek.count(d3.utcYear(d), d),x: d => d.getUTCDay(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"white":"black",text: d => d.getUTCDate(),//Math.floor(unix2doty(d.getTime())).toString().padStart(3, "0"),monospace:true,fontSize:"16px"}) ]}) : Plot.plot({title:"Gregorian calendar",padding:0,width:1280,height:200,className:"btmplot",marginTop:0,marginBottom:40,marginLeft:42,y: {tickFormat: Plot.formatWeekday("en","short"),tickSize:0,domain: [-1,0,1,2,3,4,5,6],ticks: [0,1,2,3,4,5,6],tickPadding:0, },x: {interval:1,ticks:26,label:"Week",type:"band",tickSize:0,tickPadding:2,labelOffset:36,labelArrow:false},//fx: {tickFormat: ""},style: { fontSize:"21px" },color: {range: d3.schemePastel1.concat(d3.schemePastel2.slice(4,7)).concat(d3.schemeSet1[0]),domain: months.concat("selected"),className:"cal", },marks: [ Plot.cell(datesCal, {x: d => d3.utcWeek.count(d3.utcYear(d), d),y: d => d.getUTCDay(),//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"selected": months[d.getUTCMonth()],stroke: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"darkorange":"none",strokeWidth:3,inset:.5, }), Plot.text(datesCal, {x: d => d3.utcWeek.count(d3.utcYear(d), d),y: d => d.getUTCDay(),//fx: d => d.getUTCFullYear(),text: d => d.getUTCDate() ===7? months[d.getUTCMonth()].slice(0,3) :"",y:-1,frameAnchor:"left",dy:-1,monospace:true,fontSize:"18px"}), Plot.text(datesCal, {x: d => d3.utcWeek.count(d3.utcYear(d), d),y: d => d.getUTCDay(),//fx: d => d.getUTCFullYear(),fill: d =>Math.floor(unix2doty(d.getTime())) === dotyInput ?"white":"black",//stroke: "white",text: d => d.getUTCDate(),//Math.floor(unix2doty(d.getTime())).toString().padStart(3, "0"),monospace:true,fontSize:"16px"}) ]})```:::[First day of the Gregorian calendar year]{.radiotitle}```{ojs}//| echo: false//| id: radiobuttonsviewof dotwInput = Inputs.radio(["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday", ], {value:"Sunday"})```The [radio](https://observablehq.com/@observablehq/input-radio)🔘input beneath the plots selects the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} for [Day 306]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="January 1"}, the first day of the Gregorian calendar🗓️[year]{.yellow}. Changing the [Day 306]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="January 1"} [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} shifts every date in the Gregorian calendar🗓️by one to six days depending on the number of days that [Week 0]{.darkgreen}, the first [week]{.darkgreen} of the [year]{.yellow}, contributes to the [year]{.yellow}. In contrast, [weeks]{.darkgreen} have no effect on Decalendar.Although [weeks]{.darkgreen} determine the shape of the Gregorian calendar🗓️plot, each of its [cell](https://observablehq.com/plot/marks/cell) values is a [day-of-month]{.lightblue} ([dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"}). To uniquely identify🪪a specific day in a [year]{.yellow}, a [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} must be paired with the [month]{.azul} to which it belongs. Both plots use three-letter abbreviations and the same [color🎨scheme](https://observablehq.com/@d3/color-schemes) to label🏷️[months]{.azul}, but are shifted in relation to each other by two [months]{.azul}.# Day of year (doy){id="doy"}A [dek]{.cyan} and [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} can be combined into a single number called a [day-of-year]{.cyan} ([doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}). Every cell value in the Decalendar plot is a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}. The [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} chosen by the range🎚️inputs to be highlighted with a red🟥background in the plots is [\${dotyInput}]{.cyan}. You can use the range🎚️inputs to convert a [month]{.azul} and a [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} into a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}. Try converting a special date such as your birthday🎂 or anniversary💍!There are two range🎚️inputs labeled🏷️as "day of year" because every [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} can be expressed as both a positive and a negative number. The typical range for [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-year"} is 0 to [n]{.orange}-1, but negative [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-year"} typically range from -[n]{.orange} to -1, where [n]{.orange} is the number of days in the [year]{.yellow}, either [365]{.orange} or [366]{.orange}. A [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} outside these [bounds](https://en.wikipedia.org/wiki/Upper_and_lower_bounds#:~:text=an%20upper%20bound%20or%20majorant%5B1%5D%20of%20a%20subset%20S%20of%20some%20preordered%20set%20(K%2C%20%E2%89%A4)%20is%20an%20element%20of%20K%20that%20is%20greater%20than%20or%20equal%20to%20every%20element%20of%20S.%5B2%5D%5B3%5D%20Dually%2C%20a%20lower%20bound%20or%20minorant%20of%20S%20is%20defined%20to%20be%20an%20element%20of%20K%20that%20is%20less%20than%20or%20equal%20to%20every%20element%20of%20S) represents a day in a previous or subsequent [year]{.yellow}.The current [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} can be expressed as [\${decDoty}]{.cyan} or -[\${Tminus}]{.pink}. The difference between any positive [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} and its negative equivalent is [n]{.orange}: [\${decDoty}]{.cyan} -- -[\${Tminus}]{.pink} = [\${nDaysInYear}]{.orange}. We obtain the current [dek]{.cyan} via the [dek]{.cyan} equation, [\${decDek}]{.cyan} = ⌊[\${decDoty}]{.cyan} ÷ 10⌋, and the current [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} number via the [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} equation: [\${decDotd}]{.cyan} = [\${decDoty}]{.cyan} [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 10. To combine a [dek]{.cyan} and [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"}, we multiply the [dek]{.cyan} by ten and add the [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"}: [\${decDoty}]{.cyan} = [\${decDek}]{.cyan} × 10 + [\${decDotd}]{.cyan}.Unlike [weeks]{.darkgreen} in the Gregorian calendar🗓️, [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-year"} and [deks]{.cyan} do not need to continue in an infinite unbroken sequence. The last day of the [year]{.yellow}, Day -1, is always followed by [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"}, regardless of the last 4 or 5 days of [Dek]{.cyan} 36 that extend past the end of the [year]{.yellow}. If we want to track days seamlessly across [years]{.yellow}, we can use a continuous count of days called the [day-of-[era](https://en.wikipedia.org/wiki/Calendar_era#:~:text=the%20period%20of%20time%20elapsed%20since%20one%20epoch%20of%20a%20calendar){.darklink}]{.cyan} ([doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}).# Day of era (doe){id="doe"}A [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} is essentially a [Julian day](https://en.wikipedia.org/wiki/Julian_day#:~:text=a%20continuous%20count%20of%20days%20from%20the%20beginning%20of%20the%20Julian%20period) with a different [epoch](https://en.wikipedia.org/wiki/Epoch#:~:text=an%20instant%20in%20time%20chosen%20as%20the%20origin%20of%20a%20particular%20calendar%20era). We can convert a Julian day in a [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} by subtracting [1721119.5]{.cyan} days to shift the epoch from [-4713]{.under .yellow data-bs-toggle="tooltip" data-bs-title="4714 BC"}+[268]{.under .cyan data-bs-toggle="tooltip" data-bs-title="November 24"}.[5]{.under .cyan data-bs-toggle="tooltip" data-bs-title="noon"} to [0000]{.under .yellow data-bs-toggle="tooltip" data-bs-title="1 BC"}+[000]{.under .cyan data-bs-toggle="tooltip" data-bs-title="March 1"}.[0]{.under .cyan data-bs-toggle="tooltip" data-bs-title="midnight"}. To turn a [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time#:~:text=the%20number%20of%20non%2Dleap%20seconds%20that%20have%20elapsed%20since%2000%3A00%3A00%20UTC%20on%201%C2%A0January%201970) into a [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}, we divide by [86400](https://en.wikipedia.org/wiki/Day#:~:text=average%2C%20this%20is-,24%20hours%20(86%2C400%20seconds),-.%20As%20a%20day) to convert [seconds]{.purple} to days and then add [719468.0]{.cyan} to account for the fact that the [UNIX epoch](https://en.wikipedia.org/wiki/Unix_time#:~:text=00%3A00%3A00%20UTC%20on%201%C2%A0January%201970) is [1969]{.under .yellow data-bs-toggle="tooltip" data-bs-title="1970"}+[306]{.under .cyan data-bs-toggle="tooltip" data-bs-title="January 1"}.[0]{.under .cyan data-bs-toggle="tooltip" data-bs-title="midnight"}.Dec uses [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"} for calculations, such as finding the [POSIX](https://en.wikipedia.org/wiki/POSIX#:~:text=a%20family%20of%20standards%20specified%20by%20the%20IEEE%20Computer%20Society%20for%20maintaining%20compatibility%20between%20operating%20systems)[zero-based [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}](https://pubs.opengroup.org/onlinepubs/007904875/utilities/date.html#:~:text=weekday%20as%20a%20decimal%20number%20%5B0%2C6%5D%20(0%3Dsunday)) of a given date. This [year]{.yellow}, the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} of [Christmas](https://en.wikipedia.org/wiki/Christmas#:~:text=annual%20festival%20commemorating%20the%20birth%20of%20Jesus%20Christ)🎄is [\${xmasDotw}]{.lightgreen} according to the Dec [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} equation: ([\${xmasDote}]{.cyan} + 3) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7 = [\${xmasDotw}]{.lightgreen}. In contrast to the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}, we can find the [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} of Christmas🎄without any calculation because its [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"}, [9]{.cyan}, is simply the last digit of the [integer part](https://en.wikipedia.org/wiki/Decimal#:~:text=the%20integer%20written%20to%20the%20left%20of%20the%20decimal) of its [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}: [299]{.cyan}.::: {.callout-warning}# Bad Pun Alert[Dek the halls](https://en.wikipedia.org/wiki/Deck_the_Halls#:~:text=a%20traditional%20Christmas%20carol.) with [dows]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-week"} of holly! Fa + la × 8!:::Christmas🎄is a fixed⚓️holiday because it occurs on the same [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} every [year]{.yellow}. Unlike fixed⚓️holidays, Gregorian calendar🗓️floating🛟holidays happen on a different [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} every [year]{.yellow} so that their [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} can remain constant. Dec uses the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} [delta](https://en.wikipedia.org/wiki/Delta_(letter)#:~:text=the%20difference%20operator) equation, [w~Δ~]{.lightgreen} = ([w~M~]{.lightgreen} -- [w~S~]{.lightgreen} + 7) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7, to determine which of the seven possible floating🛟holiday dates corresponds to the given [year]{.yellow}.In the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} [delta](https://en.wikipedia.org/wiki/Delta_(letter)#:~:text=the%20difference%20operator) equation, [w~M~]{.lightgreen} is the [minuend](https://en.wiktionary.org/wiki/minuend#:~:text=A%20number%20or%20quantity%20from%20which%20another%20is%20to%20be%20subtracted)[dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} destination and [w~S~]{.lightgreen} is the [subtrahend](https://en.wikipedia.org/wiki/Subtraction#:~:text=number%20being%20subtracted)[dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} starting point. To get the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} of the first [Dow 4]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Thursday"} after [Day 265]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="November 21"}, which is [Thanksgiving](https://en.wikipedia.org/wiki/Thanksgiving#:~:text=Thanksgiving%20is-,a%20national%20holiday,-celebrated%20on%20various)🦃in the United States and Brazil, we plug [4]{.lightgreen} as [w~M~]{.lightgreen} and [\${day266dotw}]{.lightgreen}, the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} of [Day 266]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="November 22"} this [year]{.yellow}, as [w~S~]{.lightgreen} into the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} [delta](https://en.wikipedia.org/wiki/Delta_(letter)#:~:text=the%20difference%20operator) equation, [\${day266dotwDiff}]{.lightgreen} = ([4]{.lightgreen} -- [\${day266dotw}]{.lightgreen} + 7) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7, and then add [w~Δ~]{.lightgreen} to [266]{.cyan}: [\${day266dotwDiff + 266}]{.cyan} = [\${day266dotwDiff}]{.lightgreen} + [266]{.cyan}.Apart from the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} and [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} [delta](https://en.wikipedia.org/wiki/Delta_(letter)#:~:text=the%20difference%20operator) equations, the Thanksgiving🦃calculation above⬆️relies on the Dec [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} equation, which is based on the [`days_from_civil`](https://howardhinnant.github.io/date_algorithms.html#days_from_civil){.mono .under} algorithm created by [Howard Hinnant](https://howardhinnant.github.io) and described in his manuscript entitled [[`chrono`]{.mono .under}-Compatible Low-Level Date Algorithms](https://howardhinnant.github.io/date_algorithms.html), to convert the [cycle](https://en.wikipedia.org/wiki/Solar_cycle_(calendar)#:~:text=the%20Gregorian%20cycle%20of%20400%20years%20has%20exactly%20146%2C097%20days%2C%20i.e.%20exactly%2020%2C871%20weeks%2C%20one%20can%20say%20that%20the%20Gregorian%20so%2Dcalled%20solar%20cycle%20lasts%20400%20years)-of-era ([coe]{.under .tool data-bs-toggle="tooltip" data-bs-title="cycle-of-era"}), [year-of-cycle]{.yellow} ([yoc]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-cycle"}), and [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} of [Day 266]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="November 22"} into its [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}:$$\text{coe} = \Biggl \lfloor \frac{\begin{cases}\text{year}&{\text{if } \text{year} \geq 0;}\\\text{year}-399&{\text{otherwise.}}\end{cases}}{400} \Biggr \rfloor$$$$\text{yoc} = \text{year} - \text{coe} \times 400$$:::{.overflowequation style="overflow-x:auto;overflow-y:hidden;"}$$\text{doe} = \text{coe}\times146097 + \text{yoc}\times365 + \lfloor\frac{\text{yoc}}{4}\rfloor - \lfloor\frac{\text{yoc}}{100}\rfloor + \text{doy}$$:::The Dec date equations, the [inverse](https://en.wikipedia.org/wiki/Inverse#:~:text=Inverse%20function%2C-,a%20function%20that%20%22reverses%22%20another%20function,-Generalized%20inverse%2C%20a)🔁of the Dec [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} equations above⬆️, are based on Howard Hinnant's [`civil_from_days`](https://howardhinnant.github.io/date_algorithms.html#civil_from_days){.mono} algorithm and are useful for obtaining Dec dates from [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"} and [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} analogs like [Unix timestamps](https://en.wikipedia.org/wiki/Unix_time#:~:text=the%20number%20of%20seconds%20that%20have%20elapsed%20since%2000%3A00%3A00%20UTC%20on%201%C2%A0January%201970) and [Julian days](https://en.wikipedia.org/wiki/Julian_day#:~:text=a%20continuous%20count%20of%20days%20from%20the%20beginning%20of%20the%20Julian%20period). Besides the [coe]{.under .tool data-bs-toggle="tooltip" data-bs-title="cycle-of-era"} and [yoc]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-cycle"}, the Dec date equations also use the [day-of-cycle]{.cyan} ([doc]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-cycle"}) of a [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} to produce the [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}'s corresponding [year]{.yellow} and [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}:$$\text{coe} = \Biggl \lfloor \frac{\begin{cases}\text{doe}&{\text{if } \text{doe} \geq 0;}\\\text{doe}-146096&{\text{otherwise.}}\end{cases}}{146097} \Biggr \rfloor$$$$\text{doc} = \text{doe} - \text{coe} \times 146097$$$$\text{yoc} = \biggl \lfloor \frac{\text{doc} - \lfloor \frac{\text{doc}}{1460} \rfloor + \lfloor \frac{\text{doc}}{36524} \rfloor - \lfloor \frac{\text{doc}}{146096} \rfloor}{365} \biggr \rfloor$$$$\text{year} = \text{yoc} + \text{coe} \times 400$$$$\text{doy} = \text{doc} - \text{yoc} \times 365 - \lfloor \frac{\text{yoc}}{4} \rfloor + \lfloor \frac{\text{yoc}}{100} \rfloor$$Dates generated by the Dec date equations are guaranteed to be in the standard [year]{.yellow}+[day]{.cyan} format. Therefore, we can standardize Dec dates by performing a [round-trip](https://en.wikipedia.org/wiki/Round-trip_format_conversion#:~:text=converting%20from%20any%20data%20representation%20and%20back%20again) date-to-[doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}-to-date conversion using the Dec [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} and date equations consecutively. This allows Dec to handle Dec dates with a non-integer [year]{.yellow} and a [day]{.cyan} outside the typical range of [0]{.cyan} ≤[day]{.cyan} ≤[365]{.cyan}.# Year of era (yoe){#yoe}A [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} is essentially a Dec date with a [year]{.yellow} that is always equal to [0]{.yellow} and a [day]{.cyan} that is [unbounded](https://en.wikipedia.org/wiki/Bounded_set#:~:text=a%20set%20which%20is%20not%20bounded). Similarly, a Dec [year-of-era]{.yellow} ([yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"}) is basically a Dec with a non-integer [year]{.yellow} and a [day]{.cyan} permanently set to [0]{.cyan}. Both [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"} and [yoes]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="years-of-era"} allow us to represent a date as a single number and obtain the difference between two dates, either in days ([d~M~]{.cyan} - [d~S~]{.cyan}) or [years]{.yellow} ([y~M~]{.yellow} -- [y~S~]{.yellow}).Compared to [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"}, [yoes]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="years-of-era"} are easier to turn into Dec dates. We can convert dates to [yoes]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="years-of-era"} and vice versa with the Dec [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"} equation: [y]{.yellow} = ⌊[y]{.yellow}⌋ + [d]{.cyan} ÷[n]{.orange}. In the Dec [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"} equation, [y]{.yellow} is the [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"}, ⌊[y]{.yellow}⌋ + [d]{.cyan} is the Dec date, ⌊[y]{.yellow}⌋ is the [year]{.yellow}, [d]{.cyan} is the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}, and [n]{.orange} is the number of days in [Year]{.yellow} ⌊[y]{.yellow}⌋. The current [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"} equation values are [\${fullfracYear}]{.yellow} = [\${decYear}]{.yellow} + [\${decDoty}]{.cyan} ÷[\${nDaysInYear}]{.orange}.Dec dates do not include [n]{.orange}, because it is not needed to specify a date, remains constant for 366, 1095, or 2920 days, has only 2 possible values: 366 if ⌊[y]{.yellow}⌋+1 is a Gregorian calendar🗓️leap [year]{.yellow} and 365 if ⌊[y]{.yellow}⌋+1 is a Gregorian calendar🗓️common [year]{.yellow}, and can be determined by applying the Gregorian calendar🗓️[leap [year]{.yellow} rule](https://en.wikipedia.org/wiki/Leap_year#:~:text=Every%20year%20that%20is%20exactly%20divisible%20by%20four%20is%20a%20leap%20year%2C%20except%20for%20years%20that%20are%20exactly%20divisible%20by%20100%2C%20but%20these%20centurial%20years%20are%20leap%20years%20if%20they%20are%20exactly%20divisible%20by%20400) to ⌊[y]{.yellow}⌋+1, as shown in the Dec [year]{.yellow} length equation:$$\text{n}=\begin{cases} 366&{\begin{align}\text{if } (\lfloor \text{y}\rfloor+1)\text{ mod }\ \ \ \ 4=0\\ \href{https://en.wikipedia.org/wiki/Logical_conjunction}{\land}(\lfloor \text{y}\rfloor+1)\text{ mod }100\neq0\\ \href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}(\lfloor \text{y}\rfloor+1)\text{ mod }400=0\end{align}}\\\\ 365&{\text{otherwise.}}\end{cases}$$Apart from its role in the Dec date and [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} equations, [n]{.orange} is needed to convert between [year]{.yellow}+[day]{.cyan} and [year]{.yellow}-[day]{.pink} Dec dates. The [year]{.yellow}-[day]{.pink} version of the Dec [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"} equation is [y]{.yellow} = ⌊[y]{.yellow}⌋ + 1 + ([d]{.cyan} -- [n]{.orange}) ÷[n]{.orange}. In essence, [d]{.cyan}-[n]{.orange} is the number of days until the start of [Year]{.yellow} ⌊[y]{.yellow}⌋+1. The current [year]{.yellow}-[day]{.pink} date, [\${nextYear}]{.yellow}-[\${TminusPadded}]{.pink}, tells us that [Year]{.yellow} [\${nextYear}]{.yellow} will begin in [\${Tminus}]{.pink} days.The distinction between [d]{.cyan} and [d]{.cyan}-[n]{.orange} can also be explained in terms of computer programming. If we think of [years]{.yellow} as [arrays](https://en.wikipedia.org/wiki/Array_(data_structure)#Element_identifier_and_addressing_formulas:~:text=a%20data%20structure%20consisting%20of%20a%20collection%20of%20elements%20(values%20or%20variables)%2C%20of%20same%20memory%20size%2C%20each%20identified%20by%20at%20least%20one%20array%20index), [d]{.cyan} and [d]{.cyan}-[n]{.orange} are like array [indexes](https://en.wikipedia.org/wiki/Array_(data_structure)#Element_identifier_and_addressing_formulas:~:text=individual%20objects%20are%20selected%20by%20an%20index) that can be used to identify array elements or combine them into groups via [slicing](https://en.wikipedia.org/wiki/Array_slicing#:~:text=an%20operation%20that%20extracts%20a%20subset%20of%20elements%20from%20an%20array). In this analogy, [n]{.orange} is the number of elements in the array, [d]{.cyan} is a [positive index](https://en.wikipedia.org/wiki/Zero-based_numbering#:~:text=a%20way%20of%20numbering%20in%20which%20the%20initial%20element%20of%20a%20sequence%20is%20assigned%20the%20index%C2%A00), and [d]{.cyan}-[n]{.orange} is a [negative index](https://en.wikipedia.org/wiki/Array_slicing#:~:text=specify%20an%20offset%20from%20the%20end%20of%20the%20array).The [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"} equation can be rearranged into the Dec [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} equation, [d]{.cyan} = ⌊[y]{.yellow} [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 1 ×[n]{.orange}⌋, where [y]{.yellow} [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 1 is the [decimal part](https://en.wikipedia.org/wiki/Fractional_part#:~:text=the%20excess%20beyond%20that%20number%27s%20integer%20part) of [y]{.yellow}. The current [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} equation values are [\${decDoty}]{.cyan} = ⌊[\${mod1FracYear}]{.yellow} ×[\${nDaysInYear}]{.orange}⌋. In Dec, a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} by itself is a floating🛟date and a [year]{.yellow}+[day]{.cyan} date is a fixed⚓️date. Unlike fixed⚓️dates, floating🛟dates do not include a [year]{.yellow} and thus can apply to any [year]{.yellow}.Fixed⚓️dates are [unsimplified](https://en.wikipedia.org/wiki/Simplification#:~:text=the%20process%20of%20replacing%20a%20mathematical%20expression%20by%20an%20equivalent%20one%2C%20that%20is%20simpler) math expressions. Instead of simplifying a fixed⚓️date into a [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"}, we can do the opposite and expand it to display additional information, such as the number of days in between it and another date. An expanded version of the current date, [\${decYear}]{.yellow}+[299]{.cyan}\${xmasDiffSign}[\${Math.abs(xmasDiff)}]{.violet}, can tell us that [\${Math.abs(xmasDiff)}]{.violet} days \${xmasDiffSince} [Day 299]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="December 25"}🎄of this [year]{.yellow}.In the example above⬆️, the minuend [\${decDoty}]{.cyan} has been expanded into the subtrahend [299]{.cyan} and the difference [\${xmasDiff}]{.violet} as per the Dec minuend equation: minuend = subtrahend + difference. If we were preparing for a rocket🚀launch, the minuend would be the current time, the subtrahend would be the planned launch time, and the difference would be the ["T-minus" countdown](https://en.wikipedia.org/wiki/Countdown#:~:text=backward%20counting%20to%20indicate%20the%20time%20remaining%20before%20an%20event).To see its minuend, subtrahend, and difference at the same time, we could rewrite the expanded date above⬆️as a Dec span🌈: [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}=[\${decYear}]{.yellow}+[299]{.cyan}\${xmasDiffSign}[\${Math.abs(xmasDiff)}]{.violet}. Unlike expanded dates, Dec spans🌈represent time intervals instead of individual dates and are structured like the minuend equation as opposed to a math expression that can be simplified to a [yoe]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-era"}.Whereas expanded dates have a set structure that does not change, Dec spans🌈can omit the subtrahend, [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}=\${xmasDiffSign}[\${Math.abs(xmasDiff)}]{.violet}, or the difference, [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}=[\${decYear}]{.yellow}+[299]{.cyan}. If the [year]{.yellow} is the same on both sides of the equals sign, it can be omitted from the minuend, [\${decDoty}]{.cyan}=[\${decYear}]{.yellow}+[299]{.cyan}\${xmasDiffSign}[\${Math.abs(xmasDiff)}]{.violet}, or from the subtrahend along with the difference: [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}=[299]{.cyan}.Dec spans🌈 can omit their entire [left](https://en.wikipedia.org/wiki/Sides_of_an_equation#:~:text=the%20expression%20on%20the%20left%20of%20the%20%22%3D%22)-hand side to indicate that the minuend is [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} of the given [year]{.yellow}. Similarly, an empty [right](https://en.wikipedia.org/wiki/Sides_of_an_equation#:~:text=The%20expression%20on%20the%20right%20side%20of%20the%20%22%3D%22%20sign)-hand side means that the subtrahend is [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} of the subsequent [year]{.yellow}. Dec spans🌈with at least one [year]{.yellow} are called fixed⚓️spans🌈. In contrast, floating🛟spans🌈do not contain a [year]{.yellow} and thus can be reused♻️ every [year]{.yellow}.Floating🛟dates and spans🌈are reusable♻️across all [years]{.yellow}, but the information displayed by expanded dates and spans🌈may not be.Information related to [weeks]{.darkgreen} is difficult to reuse♻️, because it takes 6 to 40 [years]{.yellow} for the pattern of [dows]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-week"} in a [year]{.yellow} to repeat. At the price of reusability♻️, Dec can function without [deks]{.cyan} and use [weeks]{.darkgreen} instead.# Day of week (dow){#dow}Even though Decalendar functions best with [deks]{.cyan}, Dec dates can display POSIX [zero-based](https://pubs.opengroup.org/onlinepubs/007904875/utilities/date.html#:~:text=Weekday%20as%20a%20decimal%20number%20%5B0%2C6%5D)[dows]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-week"}. Instead of the current Dec date, [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}, the [navigation bar](https://en.wikipedia.org/wiki/Navigation_bar#:~:text=a%20section%20of%20a%20graphical%20user%20interface%20intended%20to%20aid%20visitors%20in%20accessing%20information) (navbar) of my site displays the current Dec [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} date, [\${decYear}]{.yellow}\${dotw0sign}[\${dotw0doty}]{.cyan}+[\${dotw}]{.lightgreen}, by splitting the current [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}, [\${decDoty}]{.cyan}, into the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} of the first day of the current week ([Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}), [\${dotw0doty}]{.cyan}, and the current POSIX [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}: [\${dotw}]{.lightgreen}.Instead of the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} [d]{.cyan}, Dec [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates display [d]{.cyan}-[w]{.lightgreen}+[w]{.lightgreen}, where [d]{.cyan}-[w]{.lightgreen} is the [Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} and [w]{.lightgreen} is the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} associated with [d]{.cyan}. We evaluate the subtraction, [d]{.cyan}-[w]{.lightgreen}, to obtain the [Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}, but leave the addition unsimplified so we can see [w]{.lightgreen}. Dec [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates supply all of the information needed to identify specific dates and coordinate schedules based on [deks]{.cyan} or [weeks]{.darkgreen}.The [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} equation, [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} = ([doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} + 3) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7, is derived from Howard Hinnant's [`weekday_from_days`](https://howardhinnant.github.io/date_algorithms.html#weekday_from_days) algorithm. The Dec epoch [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} is [3]{.lightgreen} = ([0]{.cyan} + 3) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7. The UNIX epoch [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} is [4]{.lightgreen} = ([719468]{.cyan} + 3) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7. Depending on how [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) is defined, a negative [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} could yield a negative [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}: -[1]{.lightgreen} = (-[60]{.cyan} + 3) [mod](https://en.wikipedia.org/wiki/Modulo#:~:text=returns%20the%20remainder) 7. To convert a negative [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} into a positive [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}, we add 7.:::{.overflowtable style="overflow-x:auto;overflow-y:hidden;"}| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday || ------| ------| -------| ---------| --------| ------| --------|| 0 | 1 | 2 | 3 | 4 | 5 | 6 || -7 | -6 | -5 | -4 | -3 | -2 | -1 |:::# Week of year (woy){#woy}Dec [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates can be further expanded to include Dec [week-of-year]{.darkgreen} ([woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"}) numbers: [\${decYear}]{.yellow}+7×[\${week}]{.darkgreen}+[\${dotw}]{.lightgreen}. The current [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"}, [\${week}]{.darkgreen}, is the sum of the [Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}, [\${dotw0doty}]{.cyan}, and the first [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} of the [year]{.yellow} ([Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}), [\${doty0dotw}]{.lightgreen}, divided by 7: [\${week}]{.darkgreen} = ([\${dotw0doty}]{.cyan} + [\${doty0dotw}]{.lightgreen}) ÷ 7. The current Dec floating🛟[woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} date, 7×[\${week}]{.darkgreen}+[\${dotw}]{.lightgreen}, is equal to the sum of the current [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} and the [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}: 7 ×[\${week}]{.darkgreen} + [\${dotw}]{.lightgreen} = [\${decDoty}]{.cyan} + [\${doty0dotw}]{.lightgreen}.To create a Dec [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} date, we need two types of Dec expansion: minuend and dividend expansion. First, we turn the minuend [d]{.cyan} into the subtrahend [d]{.cyan}-[w]{.lightgreen} and the difference [w]{.lightgreen}. Then, we use the dividend equation, dividend = divisor × quotient, to convert the dividend [d]{.cyan}-[w]{.lightgreen}+[w~0~]{.lightgreen} into the divisor 7 and the quotient [W]{.darkgreen}, where [W]{.darkgreen} is the [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} and [w~0~]{.lightgreen} is the [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}.Essentially, Dec [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} dates turn [d]{.cyan}-[w]{.lightgreen} into 7×[W]{.darkgreen}+[w]{.lightgreen}-[w~0~]{.lightgreen}. Typically, only 7×[W]{.darkgreen}+[w]{.lightgreen} is displayed, because [w~0~]{.lightgreen} is not necessary to identify a date and can be calculated from a given [y]{.yellow} by flooring it, turning it into a [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}, and passing it into the [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} equation. Dec [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} dates obfuscate🫣[d]{.cyan} much more than [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates, but may be useful for [[week]{.darkgreen}-based accounting](https://en.wikipedia.org/wiki/Accounting_period#52%E2%80%9353-week_fiscal_year:~:text=used%20by%20companies%20that%20desire%20that%20their%20fiscal%20year%20always%20end%20on%20the%20same%20day%20of%20the%20week)🧾.# Day of dek (dod){#dod}While [weeks]{.darkgreen} are not evenly divisible by two, a [dek]{.cyan} can be cut✂️into two equal halves called pentadays (pents). The [Mermaid](https://mermaid.js.org) flowcharts below⬇️show Schedule [3]{.green}, the recommended [dek]{.cyan}ly schedule of [work]{.green} and [rest]{.blue} day. Schedule [3]{.green} can be short for Schedule [1]{.blue}+[3]{.green}+[1]{.blue}, if you prefer the zero-based top flowchart, or Schedule [3]{.green}+[2]{.blue}, if you favor the one-based bottom flowchart.```{mermaid}%%| label: zerobasedpent%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '29px'}}}%%flowchart TB A[0]-->B[1]-->C[2]-->D[3]-->E[4] F[5]-->G[6]-->H[7]-->I[8]-->J[9] subgraph workdays[work days] B C G H D I end subgraph restdays[rest days] A F E J workdays end style restdays color:transparent;``````{mermaid}%%| label: onebasedpent%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '29px'}}}%%flowchart TB B[1]-->C[2]-->D[3]-->E[4]-->F[5] G[6]-->H[7]-->I[8]-->J[9]-->A[10] subgraph workdays[work days] B C G H D I end subgraph restdays[rest days] A F E J workdays end style restdays color:transparent;```Both flowcharts use [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} numbers, but the bottom one starts from [Dod 1]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="second day-of-dek"} instead of [Dod 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} and refers to [Dod 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="first day-of-dek"} as [Dod 10]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="first day-of-dek"}. Like the [dods]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-dek"} in the flowcharts above⬆️, the [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-year"} in the tables below⬇️are arranged in both a zero-based (top) and a one-based (bottom) manner. The tables visualize the seamless transition between a common [year]{.yellow} and the subsequent [year]{.yellow}.|[Rest]{.blue} |[Work]{.green} |[Work]{.green} |[Work]{.green} |[Rest]{.blue} || -------------| --------------| --------------| --------------| -------------||[360]{.blue} |[361]{.green} |[362]{.green} |[363]{.green} |[364]{.blue} ||[0]{.blue} |[1]{.green} |[2]{.green} |[3]{.green} |[4]{.blue} ||[Work]{.green} |[Work]{.green} |[Work]{.green} |[Rest]{.blue} |[Rest]{.blue} || -------------| --------------| --------------| -------------| -------------||[361]{.green} |[362]{.green} |[363]{.green} |[364]{.blue} |[0]{.blue} ||[1]{.green} |[2]{.green} |[3]{.green} |[4]{.blue} |[5]{.blue} |After 4 or 8 [years]{.yellow} of consecutive pents, the Schedule [3]{.green} pattern shown in the flowcharts and tables above⬆️is interrupted by [3]{.blue} consecutive [rest]{.blue} days during the transition from a leap [year]{.yellow}. This interruption is represented by 4 empty cells in the middle row of the two tables below⬇️. The middle row contains only one day: [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"} in the top table and [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} in bottom one.|[Rest]{.blue} |[Work]{.green} |[Work]{.green} |[Work]{.green} |[Rest]{.blue} || -------------| --------------| --------------| --------------| -------------||[360]{.blue} |[361]{.green} |[362]{.green} |[363]{.green} |[364]{.blue} ||||||[365]{.blue} ||[0]{.blue} |[1]{.green} |[2]{.green} |[3]{.green} |[4]{.blue} ||[Work]{.green} |[Work]{.green} |[Work]{.green} |[Rest]{.blue} |[Rest]{.blue} || -------------| --------------| --------------| -------------| -------------||[361]{.green} |[362]{.green} |[363]{.green} |[364]{.blue} |[365]{.blue} ||||||[0]{.blue} ||[1]{.green} |[2]{.green} |[3]{.green} |[4]{.blue} |[5]{.blue} |The last pentaday (pent) in common [years]{.yellow} is Pent 72. [Day 365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"} is the only day in Pent 73. [Day 0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} is the first day of Pent 0, the first pent of the [year]{.yellow}. To get the current pent number, ${decPent}, we double the current [dek]{.cyan} number, [\${decDek}]{.cyan}, and then add 1 if the current [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"} number, [\${decDotd}]{.cyan}, is greater than 4. To avoid [off-by-one errors](https://en.wikipedia.org/wiki/Off-by-one_error#:~:text=a%20logic%20error%20that%20involves%20a%20number%20that%20differs%20from%20its%20intended%20value%20by%201), pent, [dek]{.cyan}, [dod]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-dek"}, and [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} numbers are always zero-based in Dec.Other than pent numbers, a pent can also be expressed as a span🌈. Pent 72 can be represented as [360]{.cyan}=[365]{.cyan}-[5]{.violet}, [360]{.cyan}=-[5]{.violet}, or [360]{.cyan}=[365]{.cyan}. In addition to omitting the subtrahend or the difference, we can make the subtrahend precede the minuend to indicate that we want to start from the latest day and work backwards: [365]{.cyan}=[360]{.cyan}+[5]{.violet}, [365]{.cyan}=[360]{.cyan}, or [365]{.cyan}=+[5]{.violet}.Spans🌈can also represent groups of non-consecutive days. All of the Schedule [3]{.green} [work]{.green} days in a [year]{.yellow} can be expressed as [1]{.cyan}=[4]{.cyan}=:[5]{.sienna}. In this span🌈, we start with Days [1]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 2"}, [2]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 3"}, and [3]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 4"} and then include every day that is a multiple of 5 days away from one of the starting days. The number preceded by a colon is called a step and determines which days we want to include.:::{.column-margin fig-align="center" style="text-align:center;"}](../../asset/Manual_Layout.svg):::Schedule [3]{.green} is one of six [dek]{.cyan}ly schedules that allow us to organize [work]{.green} and [rest]{.blue} days into five homogeneous columns like in the tables and flowcharts above⬆️. These schedules are like the gears⚙️of a [5-speed](https://en.m.wikipedia.org/wiki/Manual_transmission#:~:text=Common%20shift%20pattern%20for%20a%205%2Dspeed%20transmission)[manual transmission](https://en.m.wikipedia.org/wiki/Manual_transmission#:~:text=a%20multi%2Dspeed%20motor%20vehicle%20transmission%20system%20where%20gear%20changes%20require%20the%20driver%20to%20manually%20select%20the%20gears%20by%20operating%20a%20gear%20stick%20and%20clutch) in a car. The approximate speed ranges for the five gears⚙️are <5, 5 to 10, 10 to 15, 15 to 20, and ≥20 [kilometers]{.underline .tool data-bs-toggle="tooltip" data-bs-title="thousands of meters"} per [centiday]{.underline .tool data-bs-toggle="tooltip" data-bs-title="a hundredth of a day"}.In this analogy, [Neutral](https://en.m.wikipedia.org/wiki/Neutral#:~:text=the%20state%20where%20no%20gears%20are%20selected%20for%20a%20motor%20vehicle's%20transmission) (N), 1st, 2nd, 3rd, 4th, and 5th gear⚙️are Schedules [0]{.green}, [1]{.green}, [2]{.green}, [3]{.green}, [4]{.green}, and [5]{.green}, respectively. To complete the [gearshift](https://en.m.wikipedia.org/wiki/Gear_stick#:~:text=a%20metal%20lever%20attached%20to%20the%20transmission%20of%20an%20automobile) analogy, Reverse (R) would be a time machine that takes us to the past. As our driving speed changes, we would shift up to a higher gear⚙️or shift down to a lower gear⚙️. Similarly, we can switch between the six [dek]{.cyan}ly schedules as needed.The names of the [dek]{.cyan}ly schedules are derived from their respective numbers of [work]{.green} days per pent. The total🧮number of [work]{.green} days per [year]{.yellow} provided by Schedules [0]{.green}, [1]{.green}, [2]{.green}, [3]{.green}, [4]{.green}, and [5]{.green} are 0, 73, 146, 219, 292, and 365, respectively. In general, Schedule [3]{.green} should be the default and Schedule [5]{.green} should only be used temporarily during crises‼️and emergencies🚨.In addition to switching between schedules, we can also mix them to create hybrid schedules. Schedule [34]{.green} mixes Schedules [3]{.green} and [4]{.green} to obtain an annual total🧮of 255 [work]{.green} days without modifying the transition between [years]{.yellow} shown in the tables above⬆️. This annual total🧮is about 1 pent less than the 260 to 262 [work]{.green} days that we get annually from a 5-day [work]{.green}[week]{.darkgreen}.Unlike [week]{.darkgreen}ly schedules, Schedules [3]{.green} and [34]{.green} provide a consistent🎯number of [work]{.green} days every [year]{.yellow}. While Days [364]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 28"}, [365]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="February 29"}, and [0]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="March 1"} can be [work]{.green} or [rest]{.blue} days in the Gregorian calendar🗓️, these days are always [rest]{.blue} days if we follow Schedules [3]{.green} or [34]{.green}. Therefore, Schedules [3]{.green} and [34]{.green} do not require any holidays to smooth the transition between [years]{.yellow}.There are 11 United States [Federal holidays](https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/). Federal holidays that fall on a Gregorian calendar🗓️[rest]{.blue} day, [Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} or [Dow 6]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Saturday"}, are observed on the nearest Gregorian calendar🗓️[work]{.green} day: [Dow 1]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Monday"} or [Dow 5]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Friday"}. To apply this rule to Schedule [3]{.green}, we would observe the Day [110]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="June 19"}⛓️💥, [125]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="July 4"}🎆, [255]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="November 11"}🫡, and [299]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="December 25"}🎄holidays on Days [111]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="June 20"}⛓️💥, [126]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="July 5"}🎆, [256]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="November 12"}🫡, and [298]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="December 26"}🎄, respectively.With [dek]{.cyan}ly schedules, we can determine whether any date falls on a [work]{.green} or a [rest]{.blue} day with just a glance. Counterintuitively, [dek]{.cyan}ly schedules can be based on [months]{.azul} instead of [deks]{.cyan}. [Month]{.azul}-based [dek]{.cyan}ly schedules distinguish between [work]{.green} and [rest]{.blue} days based on the last digit of [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"}. The drawback of [month]{.azul}-based schedules is that [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"} reset twelve times every [year]{.yellow}.The [month]{.azul}-based Schedules [3]{.green} and [34]{.green} have 223 and 258 [work]{.green} days per [year]{.yellow}, respectively, but will require at least one holiday to avoid six consecutive [work]{.green} days during the transition from a Dec common [year]{.yellow}. The best time to switch from a [week]{.darkgreen}ly to a [dek]{.cyan}ly schedule may be from [Day 31]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="April 1"} to [93]{.under .tool data-bs-toggle="tooltip" data-bs-title="June 2"} when the original and [month]{.azul}-based versions of Schedules [3]{.green} and [34]{.green} are identical.# Day of month (dom){#dom}Dec dates can be expanded to display Dec [month]{.azul} and [POSIX [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"}](https://pubs.opengroup.org/onlinepubs/007904875/utilities/date.html#:~:text=day%20of%20the%20month%20as%20a%20decimal%20number%20%5B01%2C31%5D) numbers. The current Dec [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} date is [\${decYear}]{.yellow}+[\${monthNumber}]{.cyan}+[\${dotm}]{.lightblue}. Dec [month]{.azul} numbers are the last [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} of the previous [month]{.azul} because POSIX [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"} are one-based. For zero-based [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"}, Dec represents each [month]{.azul} with its first [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}: [\${decYear}]{.yellow}+[\${monthNumber0}]{.cyan}+[\${dotm0}]{.lightblue}. This way, Dec can support both zero- and one-based [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"}.Dec [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} dates replace the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} [d]{.cyan} from Dec dates with [d]{.cyan}-[m]{.lightblue}+[m]{.lightblue}. We evaluate the subtraction to get [d]{.cyan}-[m]{.lightblue}, the Dec [month]{.azul} number, but not the addition, so we can see [m]{.lightblue}, the [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"}. If we combine the [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} and [dow]{.under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} patterns above⬆️, we can create hybrid [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"}+[dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} Dec dates: [\${decYear}]{.yellow}+[\${monthNumber - dotw}]{.cyan}+[\${dotm}]{.lightblue}+[\${dotw}]{.lightgreen}, where [\${monthNumber - dotw}]{.cyan} is [d]{.cyan}-[m]{.lightblue}-[w]{.lightgreen}, the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} of the last [Dow 0]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="Sunday"} before the beginning of the [month]{.azul}.We can obtain Dec [month]{.azul} numbers using only a pair of hands🤲by counting index☝️and ring💍fingers as 30 days and other fingers as 31 days. For zero-based [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"}, we start counting from 0. For one-based [doms]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-month"}, we start counting from -1, as shown in the image below⬇️. To spread 12 [months]{.azul} across 10 fingers, the first and last fingers each represent 2 [months]{.azul}.:::{.hand}{{< include _left.qmd >}}{{< include _right.qmd >}}:::[[Wikimedia](https://commons.wikimedia.org/wiki/File:Typing-colour_for-finger-positions.svg)]{.handlabel}The finger🖐[mnemonic](https://en.wikipedia.org/wiki/Mnemonic#:~:text=any%20learning%20technique%20that%20aids%20information%20retention%20or%20retrieval%20in%20the%20human%20memory) described above⬆️is similar to the [knuckle👊](https://en.wikipedia.org/wiki/Knuckle_mnemonic#:~:text=a%20mnemonic%20device%20for%20remembering%20the%20number%20of%20days%20in%20the%20months%20of%20the%20Julian%20and%20Gregorian%20calendars)and [musical keyboard🎹](https://en.wikipedia.org/wiki/Month#:~:text=this%20cyclical%20pattern%20of%20month%20lengths%20matches%20the%20musical%20keyboard%20alternation%20of%20wide%20white%20keys%20(31%20days)%20and%20narrow%20black%20keys%20(30%20days))mnemonics. These mnemonics attempt to make sense of the irregular pattern of [[month]{.azul} lengths](https://en.wikipedia.org/wiki/Month#:~:text=Name-,Number,of%20days) in the Gregorian calendar🗓️. As opposed to [months]{.azul}, we do not need mnemonics, tables, or mental calculations to use [deks]{.cyan}, because all of the required information is plainly visible in the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}.# Month of year (moy){#moy}To convert [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-year"} to or from [POSIX month](https://pubs.opengroup.org/onlinepubs/007904875/utilities/date.html#:~:text=Month%20as%20a%20decimal%20number%20%5B01%2C12%5D) and [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} numbers, we can use the [month-of-year]{.azul} ([moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"}) equations from the [`civil_from_days`](https://howardhinnant.github.io/date_algorithms.html#civil_from_days){.mono .under} and [`days_from_civil`](https://howardhinnant.github.io/date_algorithms.html#days_from_civil){.mono .under} algorithms. Unlike POSIX month numbers, [moys]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="months-of-year"} are zero-based and start from [Moy 0]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="March"} instead of [Moy 10]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="January"}. As shown in the first [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"} equation below⬇️, we can obtain a [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"} from a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} or a POSIX [month]{.azul} number.:::{.overflowequation style="overflow-x:auto;overflow-y:hidden;"}$$\text{moy} = (5 \times \text{doy} + 2) \div 153 = \begin{cases}\text{month}-3&{\text{if }\text{month}\gt 2;}\\\text{month}+9&{\text{otherwise.}}\end{cases}$$:::$$\text{month} = \begin{cases}\text{moy}+3&{\text{if }\text{moy}\lt 10;}\\\text{moy}-9&{\text{otherwise.}}\end{cases}$$$$\text{dom} = \text{doy} - (153 \times \text{moy} + 2) \div 5 + 1$$$$\text{doy} = (153 \times \text{moy}+ 2) \div 5 + \text{dom} - 1$$A [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"} and its equivalent POSIX [month]{.azul} number differ by 9 in [Moy]{.azul} [10]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="January"} or [11]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="February"} and -3 in any other [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"} because the Dec epoch, [0000]{.yellow}+[000]{.cyan}, is 2 [months]{.azul} later than the Gregorian calendar🗓️epoch: -[0001]{.yellow}+[306]{.cyan}. To convert [years]{.yellow}, we add 1 to Dec [years]{.yellow} and subtract 1 from Gregorian calendar🗓️[years]{.yellow} if the [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} is greater than 305, the [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="month-of-year"} is greater than 9, or the [month]{.azul} is less than 3::::{.overflowequation style="overflow-x:auto;overflow-y:hidden;"}$$\text{Dec year} = \begin{cases}\text{Gregorian calendar year}-1&{\text{if }\text{doy}\gt 305\href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}\text{moy}\gt 9\href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}\text{month}\lt 3;}\\\text{Gregorian calendar year}&{\text{otherwise.}}\end{cases}$$::::::{.overflowequation style="overflow-x:auto;overflow-y:hidden;"}$$\text{Gregorian calendar year} = \begin{cases}\text{Dec year}+1&{\text{if }\text{doy}\gt 305\href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}\text{moy}\gt 9\href{https://en.wikipedia.org/wiki/Logical_disjunction}{\lor}\text{month}\lt 3;}\\\text{Dec year}&{\text{otherwise.}}\end{cases}$$:::# Summary{#tldr}This article describes Dec and how it can interoperate with the Gregorian calendar🗓️by minuend expanding Dec dates into [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} and [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates or dividend expanding [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"} dates into [woy]{.darkgreen .under .tool data-bs-toggle="tooltip" data-bs-title="week-of-year"} dates. On its own, Dec minuend expands dates into span🌈equivalents, but has no use for dividend expansion, because [doys]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} display [deks]{.cyan} and [dods]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-dek"} without any expansion.The flowchart below⬇️visualizes the conversion of the UNIX epoch Dec date [1969]{.yellow}+[306]{.cyan} into a Gregorian calendar🗓️[year]{.yellow}, [month]{.azul}, [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} and [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}. To obtain its associated [dow]{.lightgreen .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-week"}, we first need to convert a Dec date into a [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"}. Outside of its interoperability with the Gregorian calendar🗓️, Dec converts dates into [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"} to find the number of days in between two dates.```{mermaid}%%| label: conversionchart%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '20px'}}}%%flowchart LR L~~~Y L-->Y L-->D L-->E R-->Y M-->R[ ]:::empty D-->A D~~~B[ ]:::empty A-->G G-->R Y~~~L[ ]:::empty Y---A[ ]:::empty Y~~~A B-->M B~~~N B-->N B-->D B~~~D N~~~B E-->W subgraph decdate[Decalendar] Y[year<br>1969] D[doy<br>306] E[doe<br>719468] end subgraph gregdate[Gregorian calendar] W[dow<br>4] G[year<br>1970] M[month<br>1] N[dom<br>1] end classDef empty width:0px; click E "#doe" click W "#dow" click Y "#yoe" click D "#doy" click G "#yoe" click M "#moy" click N "#dom"```For simplicity, the flowchart above⬆️does not show conversion byproducts, such as the [coe]{.under .tool data-bs-toggle="tooltip" data-bs-title="cycle-of-era"}, [yoc]{.yellow .under .tool data-bs-toggle="tooltip" data-bs-title="year-of-cycle"}, and [doc]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-cycle"} generated during Dec [doe]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-era"} to date conversion or the [moy]{.azul .under .tool data-bs-toggle="tooltip" data-bs-title="months-of-year"} that we need in order to split a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"} into a [month]{.azul} and a [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} or combine a [month]{.azul} and a [dom]{.lightblue .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-month"} into a [doy]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="day-of-year"}. The arrows in the flowchart represent equations adapted from [[`chrono`]{.mono .under}-Compatible Low-Level Date Algorithms](https://howardhinnant.github.io/date_algorithms.html).Instead of converting Dec dates, we can expand them to view the information we need as part of the math-inspired notation of Dec. At its heart❤️, Dec is a simple system that uses only [years]{.yellow} and [days]{.cyan} for time measurement. Thanks to Dec expansion, Dec can work with other units. In this way, Dec expansion bridges the gap between the Dec and Gregorian calendars🗓️.# NextAfter reading this article, you should be able to understand the examples in my [filter](/quarto/filter), [include](/quarto/include), and [script](/quarto/script) articles, but you may want to start with my [Quarto article](/quarto). To see the full extent of the benefits that Dec provides, I recommend that you continue through the [Dec section](/dec) of my site to the [time](/dec/time)⏳, [snap](/dec/snap)🫰, and [span](/dec/span)🌈articles. Dec has a lot more to offer than just dates!```{mermaid}%%| label: datenav%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '32px'}}}%%flowchart LR A[Dec]-->B[date]-->C[time]-->D[snap]-->E[span] click A "/dec" click B "/dec/date" click C "/dec/time" click D "/dec/snap" click E "/dec/span"```In addition my Dec and Quarto articles, many other articles on my site discuss Dec. Notably, my [Jupyter](/jupyter) article compares the code underlying Dec in several programming languages, my [Reveal](/reveal) article features a presentation on Dec time measurement, and my [Observable](/observable) article describes how I demonstrate Dec in action with interactive and animated visualizations.# CiteThank you for your interest in Dec. You will find citation information for this article below⬇️. Please note that the original source of the algorithms underlying the conversion of Dec [year]{.yellow}+[day]{.cyan} dates and [does]{.cyan .under .tool data-bs-toggle="tooltip" data-bs-title="days-of-era"} is [Hinnant, Howard](https://howardhinnant.github.io). [[2021]{.yellow}+[184]{.cyan}]{.underline .tool data-bs-toggle="tooltip" data-bs-title="2021-09-01"}. “`chrono`-Compatible Low-Level Date Algorithms.” [\${decYear}]{.yellow}+[\${decDoty}]{.cyan}. <https://howardhinnant.github.io/date_algorithms.html>.```{ojs}//| echo: false//| output: false// http://howardhinnant.github.io/date_algorithms.html#civil_from_daysfunctionunix2dote(unix, zone, offset =719468) {return [(unix ??Date.now()) /86400000+ ( zone = zone ??-Math.round( (newDate).getTimezoneOffset() /144) ) /10+ offset, zone]}functiondote2date(dote, zone =0) {const cote =Math.floor(( dote >=0? dote: dote -146096 ) /146097), dotc = dote - cote *146097, yotc =Math.floor((dotc-Math.floor(dotc /1460)+Math.floor(dotc /36524)-Math.floor(dotc /146096) ) /365);return [ yotc + cote *400, dotc - (yotc *365+Math.floor(yotc /4)-Math.floor(yotc /100) ), zone]}functiondotw2diff(x, y) {return (x - y +7) %7;}dz =unix2dote(now)ydz =dote2date(...dz)functionyear2leap(year =1970) {return year %4==0&& year %100!=0|| year %400==0;}functiondote2dotw(d =719468) {return d >=-3? (d +3) %7: (d +4) %7+6}functionunix2doty(unix) {const dote = ( unix ??Date.now() ) /86400000+719468, cote =Math.floor(( dote >=0? dote: dote -146096 ) /146097), dotc = dote - cote *146097, yotc =Math.floor((dotc-Math.floor(dotc /1460)+Math.floor(dotc /36524)-Math.floor(dotc /146096) ) /365);return dotc - (yotc *365+Math.floor(yotc /4)-Math.floor(yotc /100) )}functiondate2dote(year =1969, doty =306, zone =0) {const cote =Math.floor((year >=0? year : year -399) /400), yote = year - cote *400;return [cote *146097+ yote *365+Math.floor(yote /4) -Math.floor(yote /100) + doty, zone]}functionaddN(d) { return d +365+ leapInput }functionsubN(d) { return d -365- leapInput }// https://observablehq.com/@observablehq/synchronized-inputs// https://observablehq.com/@juang1744/transform-input/1transformInput =function(target, {bind: source, transform = identity, involutory =false, invert = involutory ? transform :inverse(transform)} = {}){if (source ===undefined) { source = target; target =html`<div>${source}</div>`; }functionsourceInputHandler() { target.removeEventListener("input", targetInputHandler);setTransform(target).to(transform(source.value)).andDispatchEvent(); target.addEventListener("input", targetInputHandler); }functiontargetInputHandler() { source.removeEventListener("input", sourceInputHandler);setTransform(source).to(invert(target.value)).andDispatchEvent(); source.addEventListener("input", sourceInputHandler); } source.addEventListener("input", sourceInputHandler); target.addEventListener("input", targetInputHandler); invalidation.then(() => { source.removeEventListener("input", sourceInputHandler); target.removeEventListener("input", targetInputHandler); });sourceInputHandler();return target;}functiondoty2month(doty =0) {const m =Math.floor((5* doty +2) /153);returnMath.floor(m <10? m +3: m -9);}functionmonth2doty(month =1) {returnMath.floor( (153* (month >2? month -3: month +9) +2) /5)}functiondoty2dotm(doty =0) {const m =Math.floor((5* doty +2) /153);return doty -Math.floor((153* m +2) /5) +1;}functionset(input, value) { input.value= value; input.dispatchEvent(newEvent("input", {bubbles:true}));}setTransform = (input) => ({to: (value) => (input.value= value, {andDispatchEvent: (event=newEvent("input")) => input.dispatchEvent(event)})});functioninverse(f) {switch (f) {caseidentity:return identity;caseMath.sqrt:return square;caseMath.log:returnMath.exp;caseMath.exp:returnMath.log;default:return (x =>solve(f, x, x)); }functionsolve(f, y, x =0) {const dx =1e-6;let steps =100, deltax, fx, dfx;do { fx =f(x) dfx = (f(x + dx) - fx) || dx; deltax = dx * (fx - y)/dfx x -= deltax; } while (Math.abs(deltax) > dx &&--steps >0);return steps ===0?NaN: x; }functionsquare(x) {return x * x; }}functionidentity(x) {return x;}// https://observablehq.com/@mbostock/scrubberfunctionScrubber(values, { format = value => value, initial =0, direction =1, delay =null, autoplay =true, loop =true, loopDelay =null, alternate =false, inputStyle =""} = {}) { values =Array.from(values);const form =html`<form style="font: 18px var(--monospace); font-variant-numeric: tabular-nums; display: flex; height: 33px; align-items: center;"> <button name=b type=button style="margin-right: 0.4em; width: 5em;"></button> <label style="display: flex; align-items: center;"> <input name=i type=range min=0 max=${values.length-1} value=${initial} step=1 style=${inputStyle}> <output name=o style="margin-left: 0.4em;"></output> </label></form>`;let frame =null;let timer =null;let interval =null;functionstart() { form.b.textContent="Stop";if (delay ===null) frame =requestAnimationFrame(tick);else interval =setInterval(tick, delay); }functionstop() { form.b.textContent="Play";if (frame !==null) cancelAnimationFrame(frame), frame =null;if (timer !==null) clearTimeout(timer), timer =null;if (interval !==null) clearInterval(interval), interval =null; }functionrunning() {return frame !==null|| timer !==null|| interval !==null; }functiontick() {if (form.i.valueAsNumber=== (direction >0? values.length-1: direction <0?0:NaN)) {if (!loop) returnstop();if (alternate) direction =-direction;if (loopDelay !==null) {if (frame !==null) cancelAnimationFrame(frame), frame =null;if (interval !==null) clearInterval(interval), interval =null; timer =setTimeout(() => (step(),start()), loopDelay);return; } }if (delay ===null) frame =requestAnimationFrame(tick);step(); }functionstep() { form.i.valueAsNumber= (form.i.valueAsNumber+ direction + values.length) % values.length; form.i.dispatchEvent(newCustomEvent("input", {bubbles:true})); } form.i.oninput=event=> {if (event&&event.isTrusted&&running()) stop(); form.value= values[form.i.valueAsNumber]; form.o.value=format(form.value, form.i.valueAsNumber, values); }; form.b.onclick= () => {if (running()) returnstop(); direction = alternate && form.i.valueAsNumber=== values.length-1?-1:1; form.i.valueAsNumber= (form.i.valueAsNumber+ direction) % values.length; form.i.dispatchEvent(newCustomEvent("input", {bubbles:true}));start(); }; form.i.oninput();if (autoplay) start();elsestop(); Inputs.disposal(form).then(stop);return form;}decYear = ydz[0]nextYear = decYear +1decDoty =Math.floor(ydz[1])decDek =Math.floor(decDoty /10)decDotd = decDoty %10decPent = decDek *2+ (decDotd >4)xmasDiff = decDoty -299xmasDiffSign = xmasDiff <0?"-":"+"xmasDiffSince = xmasDiff <0?"are left until":"have passed since"xmasDote =date2dote(ydz[0],299)[0]xmasDotw =dote2dotw(xmasDote)dotw =Math.floor(dote2dotw(dz[0]))day266dotw =dote2dotw(date2dote(ydz[0],266)[0])day266dotwDiff =dotw2diff(4, day266dotw)dotm =doty2dotm(Math.floor(ydz[1]))dotm0 =String(dotm -1).padStart(2,"0")monthNumber =Math.floor(ydz[1] - dotm)monthNumber0 =String(monthNumber +1).padStart(3,"0")dotw0doty =Math.floor(ydz[1]) - dotwdoty0dote =date2dote(ydz[0],0)[0]doty0dotw =dote2dotw(doty0dote)week =Math.floor((ydz[1] + doty0dotw) /7)dotw0sign = dotw0doty <0?"-":"+"nDaysInYear =365+year2leap(ydz[0] +1)Tminus = nDaysInYear - decDotyTminusPadded = Tminus.toString().padStart(3,"0")fracYear = ydz[0] + ydz[1] / nDaysInYearfullfracYear = (fracYear).toFixed(4)mod1FracYear = (fracYear %1).toFixed(4)months = ["January","February","March","April","May","June","July","August","September","October","November","December"];monthNums = ["305","336","","31","61","92","122","153","184","214","245","275"];calYear =!leapInput && dotwInput =="Monday"?6:!leapInput && dotwInput =="Tuesday"?7:!leapInput && dotwInput =="Wednesday"?2:!leapInput && dotwInput =="Thursday"?3:!leapInput && dotwInput =="Friday"?9:!leapInput && dotwInput =="Saturday"?10:!leapInput && dotwInput =="Sunday"?11: leapInput && dotwInput =="Monday"?12: leapInput && dotwInput =="Tuesday"?24: leapInput && dotwInput =="Wednesday"?8: leapInput && dotwInput =="Thursday"?20: leapInput && dotwInput =="Friday"?4: leapInput && dotwInput =="Saturday"?16: leapInput && dotwInput =="Sunday"?28:0;datesCal = d3.utcDays(newDate(calYear,0,0),newDate(calYear,12,0));leapInput = leapscrub[1]turnInput = leapscrub[2]dates = d3.utcDays(newDate(1999,2,0),newDate(2000,1,28+ leapInput));numbers =Array.from({length:366}, (_, i) => i)set(viewof dotyInput, leapscrub[0])``````{=html}<style>div.cell:has(form.oi-3a86ea-toggle) { display: flex; flex-wrap: wrap; align-items: center;}div.observablehq > div:has(form.oi-3a86ea-toggle) { display: flex; flex-wrap: wrap; align-items: center;}div.cell:has(form.oi-3a86ea) { display: flex; flex-wrap: wrap; align-items: center;}form.oi-3a86ea-toggle { max-width: 100% !important; --input-width: 30px; --label-width: 100px; display: flex; flex-wrap: wrap; align-items: center;}form.oi-3a86ea { --input-width: 200px; padding-right: 9px;}form.oi-3a86ea-toggle > label { width: 75px;}form.oi-3a86ea-toggle > label[for="oi-3a86ea-2"] { width: 110px;}form.oi-3a86ea-toggle > input#oi-3a86ea-2 { width: 15px;}form.oi-3a86ea-toggle { width: 110px;}form.oi-3a86ea-toggle:has(input#oi-3a86ea-2) { width: 150px;}input.oi-3a86ea-input[type="checkbox"] { margin: 4px 0px 0px 0px;}div > form.oi-3a86ea > label { --label-width: 105px;}form.oi-3a86ea > div.oi-3a86ea-input > input[type="number"] { max-width: 60px;}div.column-page:has(svg.leftplot), div.column-page:has(svg.rightplot) { display: flex; justify-content: center;}div.observablehq > figure > h2 { text-align: center; font-size: 1.3rem; margin-bottom: -8px;}input[type="radio"] { margin: 1px 0px 0px 0px;}p:has(.radiotitle) { margin-top: -6px; margin-bottom: -3px;}#radiobuttons { margin-bottom: -12px;}h4.anchored { margin: 8px 0px 8px 0px;}#mermaid-1 { margin-top: 15px; margin-bottom: -20px;}div.cell-output-display:has(svg#datenavtop-mermaid.flowchart.mermaid-js) { margin-top: -5px; margin-bottom: -5px;}div.cell-output-display:has(svg#zerobasedpent-mermaid.flowchart.mermaid-js) { margin-top: -15px;}div.cell-output-display:has(svg#onebasedpent-mermaid.flowchart.mermaid-js) { margin-top: -5px; margin-bottom: -5px;}div.cell-output-display:has(svg#conversionchart-mermaid.flowchart.mermaid-js) { margin-top: -15px; margin-bottom: -15px;}div.cell-output-display:has(svg#datenavbtm-mermaid.flowchart.mermaid-js) { margin-top: -15px; margin-bottom: 5px;}span.nodeLabel > p { text-align: center;}div.hand { display: flex; flex-wrap: wrap; justify-content: center;}div.hand > svg { margin: 5px 5px 20px 5px;}p:has(span.handlabel) { margin: -20px 5px 5px 5px; width: 100%; text-align: center;}div.overflowequation { margin-top: -20px; margin-bottom: -20px;}div#leapscrubvert { margin-top: -10px;}svg.topplot { margin-top: -9px; margin-bottom: -9px; overflow: clip;}svg.btmplot { margin-top: -9px; margin-bottom: -15px; overflow: clip;}svg.leftplot { margin-top: -9px; margin-bottom: -15px; overflow: clip;}svg.rightplot { margin-top: -9px; margin-bottom: -15px; overflow: clip;}form.oi-3a86ea-checkbox { max-width: 800px;}div:has(div.description) { display: none;}div#conversionchart > div { display: flex; justify-content: center;}</style>```