diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
| commit | 8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch) | |
| tree | 22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/android-tzdata/src/lib.rs | |
| parent | 4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff) | |
chore: add vendor directory
Diffstat (limited to 'vendor/android-tzdata/src/lib.rs')
| -rw-r--r-- | vendor/android-tzdata/src/lib.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/android-tzdata/src/lib.rs b/vendor/android-tzdata/src/lib.rs new file mode 100644 index 00000000..b6b0e36c --- /dev/null +++ b/vendor/android-tzdata/src/lib.rs @@ -0,0 +1,29 @@ +//! Parser for the Android-specific tzdata file. + +mod tzdata; + +/// Tries to locate the `tzdata` file, parse it, and return the entry for the +/// requested time zone. +/// +/// # Errors +/// +/// Returns an [std::io::Error] if the `tzdata` file cannot be found and parsed, or +/// if it does not contain the requested timezone entry. +/// +/// # Example +/// +/// ```rust +/// # use std::error::Error; +/// # use android_tzdata::find_tz_data; +/// # +/// # fn main() -> Result<(), Box<dyn Error>> { +/// let tz_data = find_tz_data("Europe/Kiev")?; +/// // Check it's version 2 of the [Time Zone Information Format](https://www.ietf.org/archive/id/draft-murchison-rfc8536bis-02.html). +/// assert!(tz_data.starts_with(b"TZif2")); +/// # Ok(()) +/// # } +/// ``` +pub fn find_tz_data(tz_name: impl AsRef<str>) -> Result<Vec<u8>, std::io::Error> { + let mut file = tzdata::find_file()?; + tzdata::find_tz_data_in_file(&mut file, tz_name.as_ref()) +} |
