The DateTimeField class is the field definition for datetime
values. It stores a python datetime object as a field. If time zone information
is included in the datetime object, it will be included in the encoded data when
this is encoded/decoded.
Timezones are only encoded as minute offset from UTC. When serialized in JSON, the encoding follows the Internet Engineering Task Force RFC 3339 spec. They are not actual timezones, for example Pacific Standard Time (PST), that you could use to derive expected daylight savings behavior.
DateTimeField is provided by the protorpc.message_types
module.
Constructor
The constructor of the DateTimeField class is defined as
follows:
- class DateTimeField (number, [required=False | repeated=False])
-
Initializes a DateTimeField instance.
Arguments- number
- Number of the field. Must be unique per message class.
- required=False
- Whether or not this field is required. Mutually exclusive with the
repeatedargument; do not specifyrepeated=Trueif you userequired=True. - repeated=False
- Whether or not this field is repeated. Mutually exclusive with the
requiredargument; do not specifyrequired=Trueif you userepeated=True.
Instance Methods
DateTimeField instances have the following methods:
- value_from_message(message)
- Convert a
DateTimeMessageto adatetime. Arguments- message
- The
DateTimeMessageinstance.
- value_to_message(value)
-
Converts a
Argumentsdatetimevalue to aDateTimeMessage.- value
- Value is a
datetimeinstance.