-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add timezone. * Move implementation to cap-time-ext. The cap-std crate is intended to focus on features which are provided by Rust's `std`.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use ambient_authority::AmbientAuthority; | ||
use iana_time_zone::get_timezone; | ||
|
||
/// A reference to a timezone resource. | ||
pub struct Timezone(()); | ||
|
||
#[derive(Debug)] | ||
pub struct TimezoneError(String); | ||
|
||
impl Timezone { | ||
/// Constructs a new instance of `Self`. | ||
/// | ||
/// # Ambient Authority | ||
/// | ||
/// This uses ambient authority to accesses clocks. | ||
#[inline] | ||
pub const fn new(ambient_authority: AmbientAuthority) -> Self { | ||
let _ = ambient_authority; | ||
Self(()) | ||
} | ||
|
||
/// Returns the combined date and time with timezone. | ||
/// | ||
/// Converts NaiveTime to DateTime | ||
#[inline] | ||
pub fn timezone_name(&self) -> Result<String, TimezoneError> { | ||
get_timezone().map_err(|e| TimezoneError(e.to_string())) | ||
} | ||
} |