pub struct UnixDay(/* private fields */);Expand description
Days since the Unix Epoch. 1970-01-01 (Gregorian) is day zero.
Important: “Unix Day” is not a Unix timestamp! Neither in seconds nor milliseconds.
§Example
use sac13::prelude::*;
use sac13::day_counts::UnixDay;
const SECONDS_PER_DAY : i32 = 86400;
// This example completely ignores time zones
// and will give you the UnixDay for the timestamp in UTC;
// which technically isn't a time zone, but I think you get the gist.
let unix_timestamp_seconds = 1355313600;
let unix_day = unix_timestamp_seconds / SECONDS_PER_DAY;
let date : Date = UnixDay::new(unix_day).unwrap().convert();§About Unix Days
The name is actually made up, but the concept is simple. It’s the number of days since
the Unix Epoch, so 1.1.1970 (Gregorian) is day zero.
Java calls this EPOCH_DAY
but because epoch is a bit too unspecific for my taste I named it UnixDay.
§Why do I have to manually convert timestamps?
It was actually a very deliberate choice to not allow construction with unix timestamps directly because if you have a timestamp, you have to think about time zones, or you will get subtle bugs. To force you to think about the conversion we let you do it manually.
Implementations§
Source§impl UnixDay
impl UnixDay
Trait Implementations§
Source§impl CalendarDate for UnixDay
impl CalendarDate for UnixDay
Source§impl Ord for UnixDay
impl Ord for UnixDay
Source§impl PartialOrd for UnixDay
impl PartialOrd for UnixDay
impl Copy for UnixDay
impl Eq for UnixDay
impl StructuralPartialEq for UnixDay
Auto Trait Implementations§
impl Freeze for UnixDay
impl RefUnwindSafe for UnixDay
impl Send for UnixDay
impl Sync for UnixDay
impl Unpin for UnixDay
impl UnwindSafe for UnixDay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more