Skip to content

Commit bbf5027

Browse files
author
Charlie Saunders
committed
Switches from UTC times to local times to prevent issues with using the --today option in timezones other than GMT.
1 parent b40979e commit bbf5027

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/calculate.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use inputs::Inputs;
2-
use chrono::{Date, Duration, Utc};
2+
use chrono::{Date, Duration, Local};
33
use DateFormat;
44

55
struct Range {
6-
start: Date<Utc>,
7-
end: Date<Utc>,
8-
current: Date<Utc>,
6+
start: Date<Local>,
7+
end: Date<Local>,
8+
current: Date<Local>,
99
}
1010

1111
impl Range {
12-
fn new(start: Date<Utc>, end: Date<Utc>) -> Range {
12+
fn new(start: Date<Local>, end: Date<Local>) -> Range {
1313
Range {
1414
start,
1515
end,
@@ -23,7 +23,7 @@ impl Range {
2323
}
2424

2525
impl Iterator for Range {
26-
type Item = Date<Utc>;
26+
type Item = Date<Local>;
2727
fn next(&mut self) -> Option<Self::Item> {
2828
let start = self.start;
2929
let end = self.end;

src/inputs/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ extern crate regex;
55
mod date_string_parser;
66

77
use clap::ArgMatches;
8-
use chrono::{Date, TimeZone, Utc};
8+
use chrono::{Date, TimeZone, Local};
99
use DateFormat;
1010

1111
pub struct Inputs {
12-
pub start: Option<Date<Utc>>,
13-
pub end: Option<Date<Utc>>,
12+
pub start: Option<Date<Local>>,
13+
pub end: Option<Date<Local>>,
1414
pub offset: Option<i64>,
1515
pub format_type: DateFormat,
1616
pub list_output: bool,
@@ -21,19 +21,19 @@ impl Inputs {
2121
pub fn new(args: ArgMatches) -> Result<Inputs, &'static str> {
2222
let mut input_format_type = DateFormat::Dashes;
2323

24-
let mut start: Option<Date<Utc>> = match args.value_of("start") {
24+
let mut start: Option<Date<Local>> = match args.value_of("start") {
2525
Some(value) => {
2626
let parsed_value = date_string_parser::ParsedDateString::new(value)?;
2727
input_format_type = parsed_value.format_type;
28-
Some(Utc.ymd(parsed_value.year, parsed_value.month, parsed_value.day))
28+
Some(Local.ymd(parsed_value.year, parsed_value.month, parsed_value.day))
2929
}
3030
None => None,
3131
};
3232

33-
let mut end: Option<Date<Utc>> = match args.value_of("end") {
33+
let mut end: Option<Date<Local>> = match args.value_of("end") {
3434
Some(value) => {
3535
let parsed_value = date_string_parser::ParsedDateString::new(value)?;
36-
Some(Utc.ymd(parsed_value.year, parsed_value.month, parsed_value.day))
36+
Some(Local.ymd(parsed_value.year, parsed_value.month, parsed_value.day))
3737
}
3838
None => None,
3939
};
@@ -52,7 +52,7 @@ impl Inputs {
5252
};
5353

5454
let today = if args.is_present("today") {
55-
Some(Utc::today())
55+
Some(Local::today())
5656
} else {
5757
None
5858
};

0 commit comments

Comments
 (0)