-
Notifications
You must be signed in to change notification settings - Fork 179
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
Implement formatting for Chinese calendar with some todos #3760
Changes from 1 commit
ba3d48c
2afaf93
981a3b5
5f714a8
53995a2
29a8c95
7030380
5d1a32e
4370a0e
2b67c84
ec9517b
b971070
c61257a
1b5424d
27c7666
0c5cae8
fb2d2e0
e29f54c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,10 +284,26 @@ where | |
.month() | ||
.ok_or(Error::MissingInputField(Some("month")))? | ||
.code; | ||
|
||
let symbols = date_symbols | ||
.ok_or(Error::MissingDateSymbols)? | ||
.get_symbols_for_month(month, length, code)?; | ||
let symbol = symbols.get(code).ok_or(Error::MissingMonthSymbol(code))?; | ||
|
||
let symbol_option = symbols.get(code); //.ok_or(Error::MissingMonthSymbol(code))?; | ||
let symbol = if symbol_option.is_none() { | ||
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. I would use I would also put the 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. I put |
||
let code = code | ||
.get_normal_if_leap() | ||
.ok_or(Error::MissingMonthSymbol(code))?; | ||
let symbols = date_symbols | ||
.ok_or(Error::MissingDateSymbols)? | ||
.get_symbols_for_month(month, length, code)?; | ||
let symbol = symbols.get(code).ok_or(Error::MissingMonthSymbol(code))?; | ||
w.write_str("(leap)")?; | ||
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. Nit: Add a |
||
symbol | ||
} else { | ||
symbol_option.ok_or(Error::MissingMonthSymbol(code))? | ||
}; | ||
|
||
w.write_str(symbol)? | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,39 +60,11 @@ fn get_month_code_map(calendar: &str) -> &'static [TinyStr4] { | |
tinystr!(4, "M13"), | ||
]; | ||
|
||
static LUNAR_MONTH_CODES: &[TinyStr4] = &[ | ||
tinystr!(4, "M01"), | ||
tinystr!(4, "M02"), | ||
tinystr!(4, "M03"), | ||
tinystr!(4, "M04"), | ||
tinystr!(4, "M05"), | ||
tinystr!(4, "M06"), | ||
tinystr!(4, "M07"), | ||
tinystr!(4, "M08"), | ||
tinystr!(4, "M09"), | ||
tinystr!(4, "M10"), | ||
tinystr!(4, "M11"), | ||
tinystr!(4, "M12"), | ||
tinystr!(4, "M01L"), | ||
tinystr!(4, "M02L"), | ||
tinystr!(4, "M03L"), | ||
tinystr!(4, "M04L"), | ||
tinystr!(4, "M05L"), | ||
tinystr!(4, "M06L"), | ||
tinystr!(4, "M07L"), | ||
tinystr!(4, "M08L"), | ||
tinystr!(4, "M09L"), | ||
tinystr!(4, "M10L"), | ||
tinystr!(4, "M11L"), | ||
tinystr!(4, "M12L"), | ||
]; | ||
|
||
match calendar { | ||
"gregory" | "buddhist" | "japanese" | "japanext" | "indian" | "persian" | "roc" => { | ||
&SOLAR_MONTH_CODES[0..12] | ||
} | ||
"coptic" | "ethiopic" => SOLAR_MONTH_CODES, | ||
"chinese" => LUNAR_MONTH_CODES, | ||
"coptic" | "ethiopic" | "chinese" => SOLAR_MONTH_CODES, | ||
Manishearth marked this conversation as resolved.
Show resolved
Hide resolved
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. Please add a TODO comment here with the issue number for fixing leap month formatting |
||
_ => panic!("Month map unknown for {calendar}"), | ||
} | ||
} | ||
|
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: MonthCode is Copy, this should just take
self
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.
Done