We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
cargo today
1 parent 335f263 commit a9ba301Copy full SHA for a9ba301
src/template/day.rs
@@ -3,7 +3,10 @@ use std::fmt::Display;
3
use std::str::FromStr;
4
5
#[cfg(feature = "today")]
6
-use chrono::{Datelike, Local};
+use chrono::{Datelike, FixedOffset, Utc};
7
+
8
+#[cfg(feature = "today")]
9
+const SERVER_UTC_OFFSET: i32 = -5;
10
11
/// A valid day number of advent (i.e. an integer in range 1 to 25).
12
///
@@ -44,7 +47,8 @@ impl Day {
44
47
impl Day {
45
48
/// Returns the current day if it's between the 1st and the 25th of december, `None` otherwise.
46
49
pub fn today() -> Option<Self> {
- let today = Local::now();
50
+ let offset = FixedOffset::east_opt(SERVER_UTC_OFFSET * 3600)?;
51
+ let today = Utc::now().with_timezone(&offset);
52
if today.month() == 12 && today.day() <= 25 {
53
Self::new(u8::try_from(today.day()).ok()?)
54
} else {
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments