pub struct PhpDateTime { /* private fields */ }Expand description
A date and time with its time zone: what DateTime::format() prints and createFromFormat() returns.
Build one from a jiff civil::DateTime (read as UTC), a Timestamp (UTC), a ZonedDateTime, or with
PhpDateTime::new.
It covers every wall-clock time jiff’s civil::DateTime does (years -9999 to 9999), which is a little more than
its Timestamp: at both ends timestamp still answers, and
to_timestamp is an error.
Implementations§
Source§impl PhpDateTime
impl PhpDateTime
Sourcepub fn new(local: DateTime, zone: Zone) -> Result<Self, Error>
pub fn new(local: DateTime, zone: Zone) -> Result<Self, Error>
A wall-clock time in zone. A time that does not exist there (the hour a daylight saving change skips)
moves forward, as PHP moves it, and a time that happens twice is the first one
(Disambiguation::Compatible).
PHP does not always take the first one: for new DateTime($time, $zone) and for a createFromFormat() value
that names no zone, it takes the second when the clocks go back to UTC+0 or ahead of it, as in Europe/London,
Europe/Madrid or Australia/Sydney. Use new_with to choose.
§Errors
For an offset out of range, or when a skipped hour moves past the last date jiff supports.
Sourcepub fn new_with(
local: DateTime,
zone: Zone,
disambiguation: Disambiguation,
) -> Result<Self, Error>
pub fn new_with( local: DateTime, zone: Zone, disambiguation: Disambiguation, ) -> Result<Self, Error>
new, choosing what happens with a wall-clock time that a Zone::Named skips or repeats.
The other zones have a single offset, so disambiguation changes nothing for them.
§Errors
Those of new, and Disambiguation::Reject for a skipped or repeated time.
Sourcepub fn from_utc(utc: DateTime, zone: Zone) -> Result<Self, Error>
pub fn from_utc(utc: DateTime, zone: Zone) -> Result<Self, Error>
The instant utc (a UTC wall-clock time) seen from zone.
§Errors
For an offset out of range, or a result outside the dates jiff supports.
Sourcepub fn in_zone(&self, zone: Zone) -> Result<Self, Error>
pub fn in_zone(&self, zone: Zone) -> Result<Self, Error>
The same instant in another zone.
§Errors
For an offset out of range, or a result outside the dates jiff supports.
Sourcepub const fn offset_seconds(&self) -> i32
pub const fn offset_seconds(&self) -> i32
Seconds east of UTC at this instant (Z).
Sourcepub fn abbreviation(&self) -> &str
pub fn abbreviation(&self) -> &str
The zone abbreviation at this instant, as T prints it.
Sourcepub fn to_timestamp(&self) -> Result<Timestamp, Error>
pub fn to_timestamp(&self) -> Result<Timestamp, Error>
Sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
The Unix timestamp (U): whole seconds, rounded down as PHP does, so half a second before 1970 is -1.
Sourcepub fn to_zoned_datetime(&self) -> Result<ZonedDateTime, Error>
pub fn to_zoned_datetime(&self) -> Result<ZonedDateTime, Error>
The instant as a jiff ZonedDateTime.
§Errors
When the instant falls outside the range of jiff’s Timestamp.
Trait Implementations§
Source§impl Clone for PhpDateTime
impl Clone for PhpDateTime
Source§impl Debug for PhpDateTime
impl Debug for PhpDateTime
impl Eq for PhpDateTime
Source§impl From<&PhpDateTime> for PhpDateTime
impl From<&PhpDateTime> for PhpDateTime
Source§impl From<Timestamp> for PhpDateTime
impl From<Timestamp> for PhpDateTime
Source§impl From<ZonedDateTime> for PhpDateTime
impl From<ZonedDateTime> for PhpDateTime
Source§fn from(date: ZonedDateTime) -> Self
fn from(date: ZonedDateTime) -> Self
The wall-clock time, offset and zone of date.
Source§impl PartialEq for PhpDateTime
impl PartialEq for PhpDateTime
impl StructuralPartialEq for PhpDateTime
Auto Trait Implementations§
impl Forget for PhpDateTime
impl Freeze for PhpDateTime
impl Move for PhpDateTime
impl RefUnwindSafe for PhpDateTimewhere
String: RefUnwindSafe,
impl Send for PhpDateTime
impl Sync for PhpDateTime
impl Unpin for PhpDateTime
impl UnsafeUnpin for PhpDateTimewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const u8: UnsafeUnpin,
&'static str: UnsafeUnpin,
String: UnsafeUnpin,
impl UnwindSafe for PhpDateTime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.