Skip to content

Commit

Permalink
Gate tests for Local timezone behind clock feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGunflame committed Jun 8, 2022
1 parent 848a18f commit d1a19e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,10 @@ mod tests {
use super::Date;

use crate::oldtime::Duration;
use crate::{FixedOffset, Local, NaiveDate, TimeZone, Utc};
use crate::{FixedOffset, NaiveDate, Utc};

#[cfg(feature = "clock")]
use crate::offset::{Local, TimeZone};

#[test]
fn test_date_add_assign() {
Expand All @@ -540,6 +543,12 @@ mod tests {
let date_add = date_add.with_timezone(&timezone);

assert_eq!(date_add, date + Duration::days(5));
}

#[test]
#[cfg(feature = "clock")]
fn test_date_add_assign_local() {
let naivedate = NaiveDate::from_ymd(2000, 1, 1);

let date = Local.from_utc_date(&naivedate);
let mut date_add = date;
Expand Down Expand Up @@ -568,6 +577,12 @@ mod tests {
let date_sub = date_sub.with_timezone(&timezone);

assert_eq!(date_sub, date - Duration::days(5));
}

#[test]
#[cfg(feature = "clock")]
fn test_date_sub_assign_local() {
let naivedate = NaiveDate::from_ymd(2000, 1, 1);

let date = Local.from_utc_date(&naivedate);
let mut date_sub = date;
Expand Down
12 changes: 12 additions & 0 deletions src/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ fn test_datetime_add_assign() {
let datetime_add = datetime_add.with_timezone(&timezone);

assert_eq!(datetime_add, datetime + Duration::seconds(60));
}

#[test]
#[cfg(feature = "clock")]
fn test_datetime_add_assign_local() {
let naivedatetime = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0);

let datetime = Local.from_utc_datetime(&naivedatetime);
let mut datetime_add = datetime;
Expand Down Expand Up @@ -456,6 +462,12 @@ fn test_datetime_sub_assign() {
let datetime_sub = datetime_sub.with_timezone(&timezone);

assert_eq!(datetime_sub, datetime - Duration::minutes(90));
}

#[test]
#[cfg(feature = "clock")]
fn test_datetime_sub_assign_local() {
let naivedatetime = NaiveDate::from_ymd(2000, 1, 1).and_hms(12, 0, 0);

let datetime = Local.from_utc_datetime(&naivedatetime);
let mut datetime_sub = datetime;
Expand Down

0 comments on commit d1a19e6

Please sign in to comment.