pub struct PyDateTime(/* private fields */);Expand description
Bindings for datetime.datetime.
Values of this type are accessed via PyO3’s smart pointers, e.g. as
Py<PyDateTime> or Bound<'py, PyDateTime>.
Implementations§
Source§impl PyDateTime
impl PyDateTime
Sourcepub fn new<'py>(
py: Python<'py>,
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
microsecond: u32,
tzinfo: Option<&Bound<'py, PyTzInfo>>,
) -> PyResult<Bound<'py, PyDateTime>>
pub fn new<'py>( py: Python<'py>, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, microsecond: u32, tzinfo: Option<&Bound<'py, PyTzInfo>>, ) -> PyResult<Bound<'py, PyDateTime>>
Creates a new datetime.datetime object.
Sourcepub fn new_with_fold<'py>(
py: Python<'py>,
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
microsecond: u32,
tzinfo: Option<&Bound<'py, PyTzInfo>>,
fold: bool,
) -> PyResult<Bound<'py, PyDateTime>>
pub fn new_with_fold<'py>( py: Python<'py>, year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, microsecond: u32, tzinfo: Option<&Bound<'py, PyTzInfo>>, fold: bool, ) -> PyResult<Bound<'py, PyDateTime>>
Alternate constructor that takes a fold parameter. A true value for this parameter
signifies this this datetime is the later of two moments with the same representation,
during a repeated interval.
This typically occurs at the end of daylight savings time. Only valid if the represented time is ambiguous. See PEP 495 for more detail.
Sourcepub fn from_timestamp<'py>(
py: Python<'py>,
timestamp: f64,
tzinfo: Option<&Bound<'py, PyTzInfo>>,
) -> PyResult<Bound<'py, PyDateTime>>
pub fn from_timestamp<'py>( py: Python<'py>, timestamp: f64, tzinfo: Option<&Bound<'py, PyTzInfo>>, ) -> PyResult<Bound<'py, PyDateTime>>
Construct a datetime object from a POSIX timestamp
This is equivalent to datetime.datetime.fromtimestamp
Trait Implementations§
Source§impl PyTypeInfo for PyDateTime
impl PyTypeInfo for PyDateTime
Source§const NAME: &'static str = "PyDateTime"
const NAME: &'static str = "PyDateTime"
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&'static str>
const MODULE: Option<&'static str>
prefer using ::type_object(py).module() to get the correct runtime value
Source§const TYPE_HINT: PyStaticExpr
const TYPE_HINT: PyStaticExpr
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn is_type_of(obj: &Bound<'_, PyAny>) -> bool
fn is_type_of(obj: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.impl DerefToPyAny for PyDateTime
impl PyLayout<PyDateTime> for PyDateTime_DateTime
impl PySizedLayout<PyDateTime> for PyDateTime_DateTime
Auto Trait Implementations§
impl !Freeze for PyDateTime
impl !RefUnwindSafe for PyDateTime
impl !Send for PyDateTime
impl !Sync for PyDateTime
impl Unpin for PyDateTime
impl UnsafeUnpin for PyDateTime
impl UnwindSafe for PyDateTime
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
Source§const NAME: &'static str = const NAME: &'static str = T::NAME;
const NAME: &'static str = const NAME: &'static str = T::NAME;
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.