---
title: Ordinal date
jupyter:
  jupytext:
    text_representation:
      extension: .qmd
      format_name: quarto
      format_version: '1.0'
      jupytext_version: 1.16.4
  kernelspec:
    display_name: Lua  (XLua)
    language: lua
    name: xlua
    path: /opt/homebrew/Caskroom/miniforge/base/envs/py/share/jupyter/kernels/xlua
---


\| [Martin Laptev]()  
2024+189

My site is full of dates in the `year+day` format. The major advantage
of this format is that the `day` component can unequivocally identify
any date and time in a given year and thus can replace months, days of
the month, hours, minutes, and seconds. In essence, the `day` number can
To create all of the dates, I use three different programming languages:
Python for the [listing page](../../list), Lua for the Published date at
the top of each article, and JavaScript for the citation information at
the bottom of each article.

To test the code, I will create a separate Quarto markdown (`qmd`) file
for each of these 3 programming languages and
[embed](https://quarto.org/docs/authoring/notebook-embed.html#overview)
them into this `qmd` file.

# Lua


```{lua}
--| tags: [lua-func]
function unix2doty(unix)
  local dote = unix / 86400 + 719468
  local cykl = (
    dote >= 0 and dote
    or dote - 146096
  ) // 146097
  local dotc = dote - cykl * 146097
  local yotc = (
    dotc - dotc // 1460
    + dotc // 36524
    - dotc // 146096
  ) // 365
  return {
    math.floor(yotc + cykl * 400),
    dotc - (yotc * 365
      + yotc // 4
      - yotc // 100
  )}
end
```

```{lua}
--| tags: [lua-out0]
unix2doty(1728000000)
```

```{lua}
--| tags: [lua-out1]
unix2doty(1890000000)
```
