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

Method date

arrow-cast/src/parse.rs:69–83  ·  view source on GitHub ↗

Parses a date of the form `1997-01-31`

(&self)

Source from the content-addressed store, hash-verified

67
68 /// Parses a date of the form `1997-01-31`
69 fn date(&self) -> Option<NaiveDate> {
70 if self.mask & 0b1111111111 != 0b1101101111 || !self.test(4, b'-') || !self.test(7, b'-') {
71 return None;
72 }
73
74 let year = self.digits[0] as u16 * 1000
75 + self.digits[1] as u16 * 100
76 + self.digits[2] as u16 * 10
77 + self.digits[3] as u16;
78
79 let month = self.digits[5] * 10 + self.digits[6];
80 let day = self.digits[8] * 10 + self.digits[9];
81
82 NaiveDate::from_ymd_opt(year as _, month as _, day as _)
83 }
84
85 /// Parses a time of any of forms
86 /// - `09:26:56`

Callers 6

string_to_datetimeFunction · 0.80
date32_to_dateFunction · 0.80
timestamp_to_date32Function · 0.80
as_dateFunction · 0.80
test_timestamp_funcFunction · 0.80
value_as_dateMethod · 0.80

Calls 1

testMethod · 0.45

Tested by 1

test_timestamp_funcFunction · 0.64