Zero offset timezones should be positive (#17)

This commit is contained in:
BryanLeong authored and GitHub committed 2022-04-08 10:19:17 +02:00
1 parent 9f1edeed33
commit d157525b1c
1 file changed
+6 -1
+6 -1
View File
@@ -16,6 +16,11 @@ use crate::{parsers::message::MessageStream, DateTime, HeaderValue};
impl DateTime {
/// Returns an ISO-8601 representation of the parsed RFC5322 datetime field
pub fn to_iso8601(&self) -> String {
let tz_sign = if self.tz_before_gmt && (self.tz_hour > 0 || self.tz_minute > 0) {
"-"
} else {
"+"
};
format!(
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}{}{:02}:{:02}",
self.year,
@@ -24,7 +29,7 @@ impl DateTime {
self.hour,
self.minute,
self.second,
if self.tz_before_gmt { "-" } else { "+" },
tz_sign,
self.tz_hour,
self.tz_minute
)