Skip to content

Commit

Permalink
Move constants to lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
botahamec committed Nov 19, 2023
1 parent 2a95dc5 commit 4829b7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,10 @@ use std::error::Error;
#[cfg(feature = "rkyv")]
use rkyv::{Archive, Deserialize, Serialize};

/// The number of nanoseconds in a microsecond.
const NANOS_PER_MICRO: i32 = 1000;
/// The number of nanoseconds in a millisecond.
const NANOS_PER_MILLI: i32 = 1_000_000;
/// The number of nanoseconds in seconds.
const NANOS_PER_SEC: i32 = 1_000_000_000;
/// The number of microseconds per second.
const MICROS_PER_SEC: i64 = 1_000_000;
/// The number of milliseconds per second.
const MILLIS_PER_SEC: i64 = 1000;
/// The number of seconds in a minute.
const SECS_PER_MINUTE: i64 = 60;
/// The number of seconds in an hour.
const SECS_PER_HOUR: i64 = 3600;
/// The number of (non-leap) seconds in days.
const SECS_PER_DAY: i64 = 86_400;
/// The number of (non-leap) seconds in a week.
const SECS_PER_WEEK: i64 = 604_800;
use crate::{
MICROS_PER_SEC, MILLIS_PER_SEC, NANOS_PER_MICRO, NANOS_PER_MILLI, NANOS_PER_SEC, SECS_PER_DAY,
SECS_PER_HOUR, SECS_PER_MINUTE, SECS_PER_WEEK,
};

macro_rules! try_opt {
($e:expr) => {
Expand Down
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,25 @@ pub mod rkyv {
pub use crate::weekday::ArchivedWeekday;
}

/// The number of nanoseconds in a microsecond.
pub const NANOS_PER_MICRO: i32 = 1000;
/// The number of nanoseconds in a millisecond.
pub const NANOS_PER_MILLI: i32 = 1_000_000;
/// The number of nanoseconds in a second.
pub const NANOS_PER_SEC: i32 = 1_000_000_000;
/// The number of microseconds in a second.
pub const MICROS_PER_SEC: i64 = 1_000_000;
/// The number of millisecondsin a second.
pub const MILLIS_PER_SEC: i64 = 1000;
/// The number of seconds in a minute.
pub const SECS_PER_MINUTE: i64 = 60;
/// The number of seconds in an hour.
pub const SECS_PER_HOUR: i64 = 3600;
/// The number of (non-leap) seconds in days.
pub const SECS_PER_DAY: i64 = 86_400;
/// The number of (non-leap) seconds in a week.
pub const SECS_PER_WEEK: i64 = 604_800;

/// Out of range error type used in various converting APIs
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
pub struct OutOfRange {
Expand Down

0 comments on commit 4829b7f

Please sign in to comment.