Wikifunctions:Type proposals/Day of Roman year
Summary
Day of a Roman year represents an individual day of a Roman calendar year, i.e. a combination of Gregorian / Roman calendar Month and the day of the given month,
Uses
Prompts:
- Why should this exist?
- Useful for dates of birth, dates of death, and other events recurring on a specific day of the year
- Useful for building the Gregorian and Julian calendar date Types
- What kinds of functions would be created using this?
- given a Day of the Roman year, what is the day number of that year in a non-leap year
- what Day of a Roman year follows another?
- which of two Days of a Roman year are earlier?
- What standard concepts, if any, does this align with?
Gregorian and Julian calendars
Structure
A Day of a Roman year has two keys:
- K1 of Type Gregorian calendar month
- K2 of Type Natural number
Example values
This represents Wikipedia day, January 15:
{
"type": “Day of a Roman calendar",
"month": "January",
“day”: {
“type”: “Natural number”,
“value”: “15”
}
}
|
{
"Z1K1": “Znnn",
"ZnnnK1": "Z16101",
“ZnnnK2”: {
“Z1K1”: “Z13518”,
“Z13518K1”: “15”
}
}
|
Validator
The validator ensures that:
- the day number is within the valid range for the given month
Identity
Two days of a roman year are the same if the day and the month are the same. February 29 is not the same as March 1.
Converting to code
Python
In Python, there is no native Class for the day of the year. Instead we return the following Dict:
{
‘K1’: 1,
‘K2’: 15
}
We also take such a dictionary back to convert it into a Day of the Roman year.
JavaScript
In JavaScript, there is no native Class for the day of the year. Instead we return the following object:
<syntaxhighlight lang="javascript">{
K1: 0, K2: 15
}
Note that as with Gregorian calendar months, months are started to be counted with 0, i.e. January is 0, not 1.
We also take such an object back to convert it into a Day of the Roman year object.
Renderer
The renderer will depend on the language. We will start with a renderer outputting the month number, followed by a “/”, followed by the day number. A configuration object will allow for the easy setting of other renderers for a given language.
Parsers
The parser will depend on the language. We will start with a parser that takes a month number, followed by a “/”, followed by the day number. A configuration object will allow for the easy setting of other parsers for a given language.
Alternatives
- Unsure about the name. Day of the Gregorian year could also work.
- Not having this type could be an option, and always flatten it out wherever this is needed.
- Instead of two keys, we could have one key of natural number, which states the number of the day in the year (e.g. 15 for January 15, or 33 for February 2nd). This has the nuance of handling leap years correctly, which we avoid by splitting it up. Also, having two keys is closer to how most of us think of dates.
Comments
- Support as proposer. --DVrandecic (WMF) (talk) 20:26, 26 June 2024 (UTC)
- …