Package pywbem :: Module cim_types :: Class CIMDateTime

[frames] | no frames]

# Class CIMDateTime

source code

    object --+
             |
       CIMType --+
                 |
                CIMDateTime

A value of CIM type datetime.

The object represents either a timezone-aware point in time, or a time interval.

Instance Methods

__init__(self, dtarg) Initialize the CIMDateTime object from different types of input object. | source code

__str__(self) Return a string representing the object in CIM datetime format. | source code

__repr__(self) repr(x) | source code

__getstate__(self) | source code

__setstate__(self, arg) | source code

__cmp__(self, other) | source code

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Class Methods

now(cls, tzi=None) Factory method that returns a new CIMDateTime object representing the current date and time. | source code

fromtimestamp(cls, ts, tzi=None) Factory method that returns a new CIMDateTime object from a POSIX timestamp value and optional timezone information. | source code

Static Methods

get_local_utcoffset() Return the timezone offset of the current local timezone from UTC. | source code

Properties
| minutes_from_utc The timezone offset of a point in time object as +/- minutes from UTC.
| datetime The point in time represented by the object, as a `datetime.datetime` object.
| timedelta The time interval represented by the object, as a `datetime.timedelta` object.
| is_interval A boolean indicating whether the object represents a time interval (`True`) or a point in time (`False`).
Inherited from `object`: `__class__`

Method Details

### __init__(self, dtarg)
(Constructor)

source code

Initialize the CIMDateTime object from different types of input object.

Parameters:
  - `dtarg` - The input object, as one of the following types: An `str` or `unicode` object will be interpreted as CIM datetime format (see DSP0004) and will result in a point in time or a time interval. A `datetime.datetime` object must be timezone-aware and will result in a point in time. A `datetime.timedelta` object will result in a time interval. Another CIMDateTime object will be copied.
Raises:
  - `ValueError`
  - `TypeError`
Overrides: object.__init__

### get_local_utcoffset()
Static Method

source code

Return the timezone offset of the current local timezone from UTC.

A positive value indicates minutes east of UTC, and a negative value indicates minutes west of UTC.

### now(cls, tzi=None)
Class Method

source code

Factory method that returns a new CIMDateTime object representing the current date and time.

The optional timezone information is used to convert the CIM datetime value into the desired timezone. That does not change the point in time that is represented by the value, but it changes the value of the `hhmmss` components of the CIM datetime value to compensate for changes in the timezone offset component.

Parameters:
  - `tzi` (`datetime.tzinfo`) - Timezone information. `None` means that the current local timezone is used. The `datetime.tzinfo` object may be a MinutesFromUTC object.
Returns:
  A new CIMDateTime object representing the current date and time.

### fromtimestamp(cls, ts, tzi=None)
Class Method

source code

Factory method that returns a new CIMDateTime object from a POSIX timestamp value and optional timezone information.

A POSIX timestamp value is the number of seconds since 1970-01-01 00:00:00 UTC. Thus, a POSIX timestamp value is unambiguous w.r.t. the timezone.

The optional timezone information is used to convert the CIM datetime value into the desired timezone. That does not change the point in time that is represented by the value, but it changes the value of the `hhmmss` components of the CIM datetime value to compensate for changes in the timezone offset component.

Parameters:
  - `ts` (`int`) - POSIX timestamp value.
  - `tzi` (`datetime.tzinfo`) - Timezone information. `None` means that the current local timezone is used. The `datetime.tzinfo` object may be a MinutesFromUTC object.
Returns:
  A new CIMDateTime object representing the specified point in time.

### __str__(self)
(Informal representation operator)

source code

Return a string representing the object in CIM datetime format.

Overrides: object.__str__

### __repr__(self)
(Representation operator)

source code

repr(x)

Overrides: object.__repr__
  (inherited documentation)

Property Details

### minutes_from_utc

The timezone offset of a point in time object as +/- minutes from UTC.

A positive value of the timezone offset indicates minutes east of UTC, and a negative value indicates minutes west of UTC.

0, if the object represents a time interval.

Get Method:
  unreachable.minutes_from_utc(self) - The timezone offset of a point in time object as +/- minutes from UTC.

### datetime

The point in time represented by the object, as a `datetime.datetime` object.

`None` if the object represents a time interval.

Get Method:
  unreachable.datetime(self) - The point in time represented by the object, as a `datetime.datetime` object.

### timedelta

The time interval represented by the object, as a `datetime.timedelta` object.

`None` if the object represents a point in time.

Get Method:
  unreachable.timedelta(self) - The time interval represented by the object, as a `datetime.timedelta` object.

### is_interval

A boolean indicating whether the object represents a time interval (`True`) or a point in time (`False`).

Get Method:
  unreachable.is_interval(self) - A boolean indicating whether the object represents a time interval (`True`) or a point in time (`False`).