forked from elkowar/eww
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make formattime follow system locale (elkowar#1177)
closes elkowar#869 Co-authored-by: CrumblyLiquid <[email protected]>
- Loading branch information
1 parent
057297b
commit 1d3a186
Showing
6 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
pub mod locale; | ||
pub mod span; | ||
pub mod wrappers; | ||
|
||
pub use locale::*; | ||
pub use span::*; | ||
pub use wrappers::*; | ||
|
||
|
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,14 @@ | ||
use chrono::Locale; | ||
use std::env::var; | ||
|
||
/// Returns the `Locale` enum based on the `LC_TIME` environment variable. | ||
/// If the environment variable is not defined or is malformed use the POSIX locale. | ||
pub fn get_locale() -> Locale { | ||
let locale_string: String = | ||
var("LC_TIME").map_or_else(|_| "C".to_string(), |v| v.split(".").next().unwrap_or("C").to_string()); | ||
|
||
match (&*locale_string).try_into() { | ||
Ok(x) => x, | ||
Err(_) => Locale::POSIX, | ||
} | ||
} |
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