Comments (2)
Temporal gives 3 ways of representing a particular PlainDate
:
- ISO:
isoYear
,isoMonth
, andisoDay
with a calendar system (this is the one we use internally in the spec) - Codes:
era
,eraYear
,monthCode
, andday
- Scalars:
year
,month
, andday
(this is what ICU4X uses internally)
Being able to convert between all three representations without ambiguity is I think the most important invariant. I will call this the equivalence relation.
Temporal also defines the following invariants for the scalar properties:
year
is a signed integer representing the number of years relative to a calendar-specific epoch- The first month in every year has
month
equal to 1. The last month of every year hasmonth
equal to the monthsInYear property. day
is a positive integer representing the day of the month.
Following from these definitions and the equivalence relation are the following arithmetic invariants that I coded into ICU4X in unicode-org/icu4x#4904: The following operations must be equivalent: adding or subtracting 1 day to ISO, adding or subtracting 1 day to Codes, and adding or subtracting 1 day to Scalars. One can write a proof that these invariants must be true for the above definitions to hold.
Calendars that seem like they don't obey these invariants should be modified to do so. For example, juligreg
skips about 10 days in the 1600s, violating the definition of day
. To fix this problem, that particular month should be shortened and the day
field should be adjusted to fill the gap. The offset can and should be fixed during formatting.
For reasons the champions have discussed previously, I think it is wise for Temporal to enforce these invariants. It allows careful developers to craft calendar-independent logic: no matter which calendar is in use, there are certain operations that are always sound, operations derived from the above invariants.
from proposal-temporal.
How important are calendar internal invariants for such dates? These are invariants that are part of the definition of the calendar. For example:
Is it acceptable for an Islamic or Chinese month in the far future to have a number of days other than 29 or 30?
Is it acceptable to have an Islamic year with a number of days other than 354 or 355?
We have finally finalized a proposal named Hijri week calendar (HWC) that is a counterpart of the ISO calendar for Hijri calendars. We have a working Temporal implementation for it.
When doing so we realised that some Hijri calendars like the islamic
or the islamic-rgsa
don't follow the invariants of the Hijri calendar as you have mentioned. We considered that as a bug that will potentially be fixed in the ICU implementation.
I am mentioning this as to consider a fix for these calendars to make them compatible with the HWC as we are exploring to port the HWC to CLDR.
from proposal-temporal.
Related Issues (20)
- Temporal.Duration.prototype.{round,total}: Is CreateTemporalDuration really fallible when creating from balanced valid Duration?
- NudgeToCalendarUnit: CreateTemporalDate is fallible HOT 5
- NudgeToZonedTime: Bad named character reference for "≠"
- NudgeToZonedTime: Incorrect assertion for user-defined time zones or calendars HOT 1
- NudgeToDayOrTime: "remainder" not converted to Normalized Time Duration Record
- BubbleRelativeDuration: Wrong operator for loop condition HOT 1
- AddDate: CreateTemporalDate is fallible
- does `ZonedDateTime.from` with `offset: reject` always throw when the datetime is in a DST transition gap? if so, is that intended?
- NudgeToCalendarUnit: Wrong roundedSign for (roundedUnit - total == 0)? HOT 1
- NudgeToDayOrTime: Incorrect assertion in step 1
- Polyfill: Buddhist, Ethiopic-Amete-Alem, Indian, Islamic, and Persian calendar return non-undefind era HOT 3
- CalendarFieldDescriptors: Require eraYear to be alway positive? HOT 8
- Polyfill: Allow alternate era codes
- RoundRelativeDuration: Disallow edge case in roundingIncrement within year/month HOT 5
- SystemDateTime, SystemZonedDateTime: "calendarLike" argument is always constant string "iso8601"
- Polyfill : undefined weekOfYear and yearOfWeek with calendarId = "islamic-civil" HOT 3
- Move AvailableCalendars from 402 into 262
- Implement calendar canonicalization to match 402
- ZonedDateTime.from() / .with() overflow option default HOT 1
- ZonedDateTime.startOfDay: is it guaranteed to be the first instant in a calendar day? HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-temporal.