Skip to content

tests: set timezone to UTC0 in integration tests #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use std::env;

use chrono::{DateTime, FixedOffset};
use parse_datetime::{parse_datetime, parse_datetime_at_date};

pub fn check_absolute(input: &str, expected: &str) {
env::set_var("TZ", "UTC0");

let parsed = match parse_datetime(input) {
Ok(v) => v,
Err(e) => panic!("Failed to parse date from value '{input}': {e}"),
Expand All @@ -18,6 +22,8 @@ pub fn check_absolute(input: &str, expected: &str) {
}

pub fn check_relative(now: DateTime<FixedOffset>, input: &str, expected: &str) {
env::set_var("TZ", "UTC0");

let parsed = match parse_datetime_at_date(now.into(), input) {
Ok(v) => v,
Err(e) => panic!("Failed to parse date from value '{input}': {e}"),
Expand Down