1
0
mirror of https://github.com/bspeice/dtparse synced 2024-12-22 04:18:09 -05:00

Refactor if logic for resolve_ymd.

This commit is contained in:
Mark H. Colburn 2018-06-25 10:49:30 -07:00
parent d7031ee279
commit f819ec8e40

View File

@ -679,26 +679,26 @@ impl YMD {
"More than three YMD values".to_owned(),
));
}
if len_ymd == 1 || (self.mstridx.is_some() && len_ymd == 2) {
if len_ymd == 1 {
if self.mstridx.is_some() {
month = Some(self._ymd[self.mstridx.unwrap()]);
other = if len_ymd == 1 {
Some(self._ymd[0])
let other = self._ymd[0];
if other > 31 {
year = Some(other);
} else {
Some(self._ymd[1 - self.mstridx.unwrap()])
};
} else {
other = Some(self._ymd[0]);
}
if len_ymd > 1 || self.mstridx.is_some() {
if other.unwrap_or(0) > 31 {
year = other;
} else {
day = other;
day = Some(other);
}
}
} else if len_ymd == 2 {
if self.mstridx.is_some() {
month = Some(self._ymd[self.mstridx.unwrap()]);
let other = self._ymd[1 - self.mstridx.unwrap()];
if other > 31 {
year = Some(other);
} else {
day = Some(other);
}
} else {
if self._ymd[0] > 31 {
dmy!(None, Some(self._ymd[1]), Some(self._ymd[0]));
} else if self._ymd[1] > 31 {
@ -708,6 +708,7 @@ impl YMD {
} else {
dmy!(Some(self._ymd[1]), Some(self._ymd[0]), None);
}
}
} else if len_ymd == 3 {
if self.mstridx == Some(0) {
if self._ymd[1] > 31 {