Wikifunctions:Type proposals/Gregorian year
Summary
This represents a year of the proleptic Gregorian calendar.
Uses
Prompts:
- Why should this exist?
Years are frequently represented in encyclopedic content.
- What kinds of functions would be created using this?
- How many years between two years?
- Is this a leap year?
- Which year will it be that many years later?
- What century is the given year in?
- What standard concepts, if any, does this align with?
The widely used Gregorian calendar.
Structure
A Gregorian year has two keys:
- K1 of Type Gregorian era
- K2 of Type Z13518/Natural number
Example values
This represents the year 2001, when Wikipedia was founded.
{
"type": "Gregorian year",
"era": "CE",
“year”: {
“type”: “Natural number”,
“value”: “2001”
}
}
|
{
"Z1K1": "Znnn",
"ZnnnK1": "Zmmm",
“ZnnnK2”: {
“Z1K1”: “Z13518”,
“Z13518”: “2001”
}
}
|
Validator
The validator ensures that:
- the year is not 0
Identity
Two Gregorian years are the same if the era and the year are the same.
Converting to code
Python
In Python, there is no native Class for a Gregorian year. Instead we return the following Dict:
{
‘K1’: True,
‘K2’: 2001
}
We also take such a dictionary back to convert it into a Gregorian year.
JavaScript
In JavaScript, there is no native Class for the day of the year. Instead we return the following object:
{
K1: true,
K2: 2001
}
We also take such an object back to convert it into a Gregorian year object.
Renderer
The renderer will depend on the language. We will introduce a default renderer outputting the year number, preceded by a “-” in case of a year BCE. A configuration object will allow for the easy setting of other parsers for a given language.
Parsers
The parser will depend on the language. We will start with a parser that takes a number possibly preceded by a “-”. A configuration object will allow for the easy setting of other parsers for a given language.
Alternatives
- The main alternative is to represent the year as an Integer, instead of a natural number with an Era. That is very much a possibility. The only drawback of that is to be careful using the usual math functions for addition and subtraction across the era boundary, due to the missing zero. For an ISO 8601 based year though, that would indeed not be useful.
Comments
Support as proposer. --DVrandecic (WMF) (talk) 20:19, 26 June 2024 (UTC)
- …