Skip to content

Commit

Permalink
优化生成VDate
Browse files Browse the repository at this point in the history
  • Loading branch information
parabala committed Jul 5, 2024
1 parent 423bca1 commit 008a257
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions protocol/src/vector/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ impl VDate {
// 2024-11-01 -> {24, 11}
pub fn from(d: &RingSlice) -> Self {
if let Some(first) = d.find(0, b'-') {
let y = d.try_str_num(0..first).ok_or_else(|| 0).unwrap();
let y = d.try_str_num(0..first).unwrap_or(0);
if let Some(second) = d.find(first + 1, b'-') {
let m = d.try_str_num(first + 1..second).ok_or_else(|| 0).unwrap();
let m = d.try_str_num(first + 1..second).unwrap_or(0);
if y > 0 && m > 0 {
return Self {
year: y.checked_rem(100).unwrap_or_default() as u8,
year: y.checked_rem(100).unwrap_or(0) as u8,
month: m as u8,
};
}
Expand Down

0 comments on commit 008a257

Please sign in to comment.