Wikifunctions:Type proposals/Day of the week
Done: Day of the week (Z17402)
Summary
An enumeration for the seven days of the week.
Uses
Why should this exist?
To represent the seven days of the week, which are often used in combination with dates.
There is already a date conversion to weekday that would benefit from this type (and probably should be updated once the type is available):
What kinds of functions would be created using this?
- How many Sundays are in a given month in a particular year?
- Does a particular date fall on a Sunday?
- What date is the first Tuesday in November in a particular year? (Melbourne Cup (Q1311060))
- What date is day after the first Monday in November in a particular year? (Election Day (Q11704))
- What day of the week is the leap day in a particular leap year?
- Following and previous days (also, more than just the immediately following or previous)
What standard concepts, if any, does this align with?
Structure
Like all enumeration types, the day of the week consists of a single key. The key is an identity key.
Values
There are seven values. Internal representations of these numbers could start on different days. This numbering lines up with python weekday()
0. Monday 1. Tuesday 2. Wednesday 3. Thursday 4. Friday 5. Saturday 6. Sunday
but javascript starts with 0=Sunday.
Example values
Value
{
"type": "Day of the week",
"value": "Sunday"
}
|
{
"Z1K1": "Znnnnn",
"ZnnnnnK1": "Zmmmmm"
}
|
Validator
The validator ensures that:
- the identity key points directly to a value of Day of the week
Identity
Two Days of the week are the same if their identity is the same ZID.
Converting to code
The numbers in Python and JavaScript both start at 0, but start with different days.
Python
Values start with 0=Monday.
JavaScript
Values start with 0=Sunday.
Renderer
As for all enumerations, the renderer displays the label of the value object.
Parsers
As with all enumerations, there is no parser, but a selector based on pre-defined values.
Alternatives
- Having Python and JS start with different Days may cause confusion:
- For either language we could decide to start on 0 or 1.
- For either language we could decide to start the Days of the week on any day.
Comments
Support as proposer. --99of9 (talk) 03:42, 6 June 2024 (UTC)
Support, prefer JS's 0=Sunday but whichever we go with should be documented very well --DannyS712 (talk) 06:39, 12 June 2024 (UTC)
- On the other hand, it seems there isn't a big problem with different numberings - for months, Gregorian calendar month to JS number (Z16132) has January=0 and Gregorian calendar month to Python int (Z16133) has January=1 --DannyS712 (talk) 06:44, 12 June 2024 (UTC)
- @DannyS712: yep, we can do whatever is most appropriate for each programming language. --DVrandecic (WMF) (talk) 00:07, 19 June 2024 (UTC)
- On the other hand, it seems there isn't a big problem with different numberings - for months, Gregorian calendar month to JS number (Z16132) has January=0 and Gregorian calendar month to Python int (Z16133) has January=1 --DannyS712 (talk) 06:44, 12 June 2024 (UTC)
Support --Denny (talk) 00:16, 19 June 2024 (UTC)
Support --Dolphyb (talk) 17:09, 24 June 2024 (UTC)
Support --ScienceD90 (talk) 17:39, 24 June 2024 (UTC)