Use system tzinfo instead of compiling it into the binary
This commit is contained in:
parent
36aa6abcb9
commit
d7df47eba4
6 changed files with 46 additions and 207 deletions
|
|
@ -1,7 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use chrono_tz::Tz;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Time {
|
||||
|
|
@ -331,6 +330,6 @@ pub enum Command {
|
|||
pub struct File {
|
||||
pub name: PathBuf,
|
||||
pub includes: Vec<PathBuf>,
|
||||
pub timezone: Option<Tz>,
|
||||
pub timezone: Option<String>,
|
||||
pub commands: Vec<Command>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use std::path::{Path, PathBuf};
|
|||
use std::result;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use chrono_tz::Tz;
|
||||
use pest::error::ErrorVariant;
|
||||
use pest::iterators::Pair;
|
||||
use pest::prec_climber::{Assoc, Operator, PrecClimber};
|
||||
|
|
@ -38,15 +37,9 @@ fn parse_include(p: Pair<Rule>) -> String {
|
|||
p.into_inner().next().unwrap().as_str().to_string()
|
||||
}
|
||||
|
||||
fn parse_timezone(p: Pair<Rule>) -> Result<Tz> {
|
||||
fn parse_timezone(p: Pair<Rule>) -> String {
|
||||
assert_eq!(p.as_rule(), Rule::timezone);
|
||||
let span = p.as_span();
|
||||
p.into_inner()
|
||||
.next()
|
||||
.unwrap()
|
||||
.as_str()
|
||||
.parse()
|
||||
.map_err(|_| error(span, "invalid timezone"))
|
||||
p.into_inner().next().unwrap().as_str().trim().to_string()
|
||||
}
|
||||
|
||||
fn parse_number(p: Pair<Rule>) -> i32 {
|
||||
|
|
@ -720,7 +713,7 @@ fn parse_command(p: Pair<Rule>, file: &mut File) -> Result<()> {
|
|||
file.includes.push(parent.join(parse_include(p)));
|
||||
}
|
||||
Rule::timezone => match file.timezone {
|
||||
None => file.timezone = Some(parse_timezone(p)?),
|
||||
None => file.timezone = Some(parse_timezone(p)),
|
||||
Some(_) => fail(p.as_span(), "cannot set timezone multiple times")?,
|
||||
},
|
||||
Rule::task => file.commands.push(Command::Task(parse_task(p)?)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue