File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ use std::fmt::Display;
3
3
use std:: str:: FromStr ;
4
4
5
5
#[ cfg( feature = "today" ) ]
6
- use chrono:: { Datelike , Local } ;
6
+ use chrono:: { Datelike , FixedOffset , Utc } ;
7
+
8
+ const SERVER_UTC_OFFSET : i32 = -5 ;
7
9
8
10
/// A valid day number of advent (i.e. an integer in range 1 to 25).
9
11
///
@@ -44,7 +46,8 @@ impl Day {
44
46
impl Day {
45
47
/// Returns the current day if it's between the 1st and the 25th of december, `None` otherwise.
46
48
pub fn today ( ) -> Option < Self > {
47
- let today = Local :: now ( ) ;
49
+ let offset = FixedOffset :: east_opt ( SERVER_UTC_OFFSET * 3600 ) ?;
50
+ let today = Utc :: now ( ) . with_timezone ( & offset) ;
48
51
if today. month ( ) == 12 && today. day ( ) <= 25 {
49
52
Self :: new ( u8:: try_from ( today. day ( ) ) . ok ( ) ?)
50
53
} else {
You can’t perform that action at this time.
0 commit comments