Skip to content

Commit 4d9afba

Browse files
authored
Merge pull request #172 from yuankunzhang/minor-refactor
refactor: put the epoch and timezone module into separate files
2 parents 98d4931 + 05677a8 commit 4d9afba

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/items/epoch.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// For the full copyright and license information, please view the LICENSE
2+
// file that was distributed with this source code.
3+
4+
use winnow::{combinator::preceded, ModalResult, Parser};
5+
6+
use super::primitive::{dec_int, s};
7+
8+
pub fn parse(input: &mut &str) -> ModalResult<i32> {
9+
s(preceded("@", dec_int)).parse_next(input)
10+
}

src/items/mod.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,15 @@
2929
#![allow(deprecated)]
3030
mod combined;
3131
mod date;
32+
mod epoch;
3233
mod ordinal;
3334
mod primitive;
3435
mod relative;
3536
mod time;
37+
mod timezone;
3638
mod weekday;
3739

38-
mod epoch {
39-
use winnow::{combinator::preceded, ModalResult, Parser};
40-
41-
use super::primitive::{dec_int, s};
42-
43-
pub fn parse(input: &mut &str) -> ModalResult<i32> {
44-
s(preceded("@", dec_int)).parse_next(input)
45-
}
46-
}
47-
48-
mod timezone {
49-
use winnow::ModalResult;
50-
51-
use super::time;
52-
53-
pub(crate) fn parse(input: &mut &str) -> ModalResult<time::Offset> {
54-
time::timezone(input)
55-
}
56-
}
57-
58-
use chrono::NaiveDate;
59-
use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Timelike};
60-
40+
use chrono::{DateTime, Datelike, FixedOffset, NaiveDate, TimeZone, Timelike};
6141
use primitive::space;
6242
use winnow::{
6343
combinator::{alt, trace},

src/items/timezone.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// For the full copyright and license information, please view the LICENSE
2+
// file that was distributed with this source code.
3+
4+
use winnow::ModalResult;
5+
6+
use super::time;
7+
8+
pub(crate) fn parse(input: &mut &str) -> ModalResult<time::Offset> {
9+
time::timezone(input)
10+
}

0 commit comments

Comments
 (0)