-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cyclic year to FormattableYear
#3581
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
FormattableYear
field cyclic
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,6 @@ impl FromStr for Era { | |
} | ||
|
||
/// Representation of a formattable year. | ||
/// | ||
/// More fields may be added in the future, for things like | ||
/// the cyclic or extended year | ||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
#[non_exhaustive] | ||
pub struct FormattableYear { | ||
|
@@ -49,6 +46,10 @@ pub struct FormattableYear { | |
/// The year number in the current era (usually 1-based). | ||
pub number: i32, | ||
|
||
/// The year in the current cycle for cyclic calendars; | ||
/// can be ignored and set to any value for non-cyclic calendars. | ||
pub cyclic: i32, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: this should probably be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I made this an Option with all currently existing calendars having this field set to None |
||
|
||
/// The related ISO year. This is normally the ISO (proleptic Gregorian) year having the greatest | ||
/// overlap with the calendar year. It is used in certain date formatting patterns. | ||
/// | ||
|
@@ -62,10 +63,11 @@ impl FormattableYear { | |
/// | ||
/// Other fields can be set mutably after construction | ||
/// as needed | ||
pub fn new(era: Era, number: i32) -> Self { | ||
pub fn new(era: Era, number: i32, cyclic: i32) -> Self { | ||
Self { | ||
era, | ||
number, | ||
cyclic, | ||
related_iso: None, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should probably keep the comment around for extended year
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the comment back in