mirror of
https://github.com/bspeice/dtparse
synced 2024-12-22 04:18:09 -05:00
...I may be an idiot.
This commit is contained in:
parent
c566c5b7c8
commit
2b90bf6ed7
@ -80,7 +80,7 @@ tests = {
|
|||||||
'1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z',
|
'1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z',
|
||||||
'Tue Apr 4 00:22:12 PDT 1995'
|
'Tue Apr 4 00:22:12 PDT 1995'
|
||||||
],
|
],
|
||||||
'test_fuzzy': [
|
'test_fuzzy_tzinfo': [
|
||||||
'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.'
|
'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.'
|
||||||
],
|
],
|
||||||
'test_parse_default_ignore': [
|
'test_parse_default_ignore': [
|
||||||
@ -153,10 +153,10 @@ def test_parse_default_ignore(i, s):
|
|||||||
return TEST_PARSE_DEFAULT_IGNORE.format(i=i, d=d, s=s)
|
return TEST_PARSE_DEFAULT_IGNORE.format(i=i, d=d, s=s)
|
||||||
|
|
||||||
|
|
||||||
def test_fuzzy(i, s):
|
def test_fuzzy_tzinfo(i, s):
|
||||||
d = parse(s, fuzzy=True)
|
d = parse(s, fuzzy=True)
|
||||||
|
|
||||||
return TEST_FUZZY.format(i=i, d=d, s=s)
|
return TEST_FUZZY_TZINFO.format(i=i, d=d, s=s, offset=int(d.tzinfo._offset.total_seconds()))
|
||||||
|
|
||||||
# Here lies all the ugly junk.
|
# Here lies all the ugly junk.
|
||||||
TEST_HEADER = '''
|
TEST_HEADER = '''
|
||||||
@ -409,14 +409,14 @@ fn test_parse_default_ignore{i}() {{
|
|||||||
Some(default_rsdate), false, HashMap::new());
|
Some(default_rsdate), false, HashMap::new());
|
||||||
}}\n'''
|
}}\n'''
|
||||||
|
|
||||||
TEST_FUZZY = '''
|
TEST_FUZZY_TZINFO = '''
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fuzzy{i}() {{
|
fn test_fuzzy{i}() {{
|
||||||
let info = ParserInfo::default();
|
let info = ParserInfo::default();
|
||||||
let pdt = PyDateTime {{
|
let pdt = PyDateTime {{
|
||||||
year: {d.year}, month: {d.month}, day: {d.day},
|
year: {d.year}, month: {d.month}, day: {d.day},
|
||||||
hour: {d.hour}, minute: {d.minute}, second: {d.second},
|
hour: {d.hour}, minute: {d.minute}, second: {d.second},
|
||||||
micros: {d.microsecond}, tzo: None
|
micros: {d.microsecond}, tzo: Some({offset})
|
||||||
}};
|
}};
|
||||||
parse_fuzzy_and_assert(pdt, None, info, "{s}", None, None, true, false,
|
parse_fuzzy_and_assert(pdt, None, info, "{s}", None, None, true, false,
|
||||||
None, false, HashMap::new());
|
None, false, HashMap::new());
|
||||||
|
@ -718,7 +718,7 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
} else if !self.info.get_jump(&l[i]) || fuzzy {
|
} else if !(self.info.get_jump(&l[i]) || fuzzy) {
|
||||||
return Err(ParseError::UnrecognizedToken(l[i].clone()));
|
return Err(ParseError::UnrecognizedToken(l[i].clone()));
|
||||||
} else {
|
} else {
|
||||||
skipped_idxs.push(i);
|
skipped_idxs.push(i);
|
||||||
|
@ -1740,7 +1740,7 @@ fn test_fuzzy0() {
|
|||||||
let pdt = PyDateTime {
|
let pdt = PyDateTime {
|
||||||
year: 2003, month: 9, day: 25,
|
year: 2003, month: 9, day: 25,
|
||||||
hour: 10, minute: 49, second: 41,
|
hour: 10, minute: 49, second: 41,
|
||||||
micros: 0, tzo: None
|
micros: 0, tzo: Some(-10800)
|
||||||
};
|
};
|
||||||
parse_fuzzy_and_assert(pdt, None, info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, false,
|
parse_fuzzy_and_assert(pdt, None, info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, false,
|
||||||
None, false, HashMap::new());
|
None, false, HashMap::new());
|
||||||
|
Loading…
Reference in New Issue
Block a user