MCPcopy Create free account
hub / github.com/apache/arrow-rs / parse_date32

Function parse_date32

arrow-cast/src/parse.rs:1795–1830  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1793
1794 #[test]
1795 fn parse_date32() {
1796 let cases = [
1797 "2020-09-08",
1798 "2020-9-8",
1799 "2020-09-8",
1800 "2020-9-08",
1801 "2020-12-1",
1802 "1690-2-5",
1803 "2020-09-08 01:02:03",
1804 ];
1805 for case in cases {
1806 let v = date32_to_datetime(Date32Type::parse(case).unwrap()).unwrap();
1807 let expected = NaiveDate::parse_from_str(case, "%Y-%m-%d")
1808 .or(NaiveDate::parse_from_str(case, "%Y-%m-%d %H:%M:%S"))
1809 .unwrap();
1810 assert_eq!(v.date(), expected);
1811 }
1812
1813 let err_cases = [
1814 "",
1815 "80-01-01",
1816 "342",
1817 "Foo",
1818 "2020-09-08-03",
1819 "2020--04-03",
1820 "2020--",
1821 "2020-09-08 01",
1822 "2020-09-08 01:02",
1823 "2020-09-08 01-02-03",
1824 "2020-9-8 01:02:03",
1825 "2020-09-08 1:2:3",
1826 ];
1827 for case in err_cases {
1828 assert_eq!(Date32Type::parse(case), None);
1829 }
1830 }
1831
1832 #[test]
1833 fn parse_date32_extended_year() {

Callers

nothing calls this directly

Calls 2

date32_to_datetimeFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected