Hello,
Is it possible to get support for months is not present in the Duration to ISO8601 string here. The same scaling logic of 30 days in a month when converting the string to Duration could be used.
|
impl fmt::Display for Duration { |
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
|
if !self.positive { |
|
write!(f, "-")?; |
|
} |
|
write!(f, "P")?; |
|
if self.day != 0 { |
|
let year = self.day / 365; |
|
if year != 0 { |
|
write!(f, "{year}Y")?; |
|
} |
|
let day = self.day % 365; |
|
if day != 0 { |
|
write!(f, "{day}D")?; |
|
} |
|
} |
|
if self.second != 0 || self.microsecond != 0 { |
|
let (hour, minute, sec) = self.to_hms(); |
|
write!(f, "T")?; |
|
if hour != 0 { |
|
write!(f, "{hour}H")?; |
|
} |
|
if minute != 0 { |
|
write!(f, "{minute}M")?; |
|
} |
|
if sec != 0 || self.microsecond != 0 { |
|
write!(f, "{sec}")?; |
|
if self.microsecond != 0 { |
|
let mut s = arrayvec::ArrayString::<6>::new(); |
|
write!(s, "{:06}", self.microsecond)?; |
|
write!(f, ".{}", s.trim_end_matches('0'))?; |
|
} |
|
write!(f, "S")?; |
|
} |
|
} |
|
if self.second == 0 && self.microsecond == 0 && self.day == 0 { |
|
write!(f, "T0S")?; |
|
} |
|
Ok(()) |
|
} |
|
} |
Or is there a specific reason that this was never implemented?
Thanks
Hello,
Is it possible to get support for months is not present in the
Durationto ISO8601 string here. The same scaling logic of 30 days in a month when converting the string toDurationcould be used.speedate/src/duration.rs
Lines 61 to 101 in 6fafc2c
Or is there a specific reason that this was never implemented?
Thanks