DateTimeField クラス
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
DateTimeField
クラスは、日時型の値のフィールド定義です。これには、Python の日時オブジェクトがフィールドとして保存されます。タイムゾーン情報が日時オブジェクトに含まれている場合、その情報はエンコード / デコード時にエンコード データに含まれます。
タイムゾーンは、UTC からの分単位のオフセットとしてのみエンコードされます。JSON でシリアル化する場合は、インターネット技術特別調査委員会の RFC 3339 仕様に従ってエンコードされます。これは、想定される夏時間の動作を得るために使用できる実際のタイムゾーン(太平洋標準時(PST)など)ではありません。
DateTimeField
は、protorpc.message_types
モジュールによって提供されます。
コンストラクタ
DateTimeField
クラスのコンストラクタは、次のように定義されます。
- class
DateTimeField
(number,
[required=False
| repeated=False])
-
DateTimeField インスタンスを初期化します。
引数
- number
- フィールドの番号。メッセージ クラスごとに一意でなければなりません。
- required=False
- このフィールドが必須かどうかを指定します。
repeated
引数と同時に指定することはできません。required=True
を使用する場合、repeated=True
は指定しないでください。
- repeated=False
- このフィールドが反復フィールドかどうかを指定します。
required
引数と同時に指定することはできません。repeated=True
を使用する場合、required=True
は指定しないでください。
インスタンス メソッド
DateTimeField
インスタンスには、次のメソッドがあります。
- value_from_message(message)
DateTimeMessage
を datetime
に変換します。引数- message
DateTimeMessage
インスタンス。
- value_to_message(value)
-
datetime
値を DateTimeMessage
に変換します。
引数
- value
- value は
datetime
インスタンスです。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-04-15 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-04-15 UTC。"],[[["The `DateTimeField` class defines fields for datetime values, storing Python datetime objects and encoding timezone information as a minute offset from UTC."],["Timezone data in `DateTimeField` is encoded according to RFC 3339 when serialized in JSON, but it does not represent actual timezones like PST."],["The constructor of `DateTimeField` takes a `number` argument for field identification, along with optional `required` and `repeated` arguments that are mutually exclusive."],["`DateTimeField` instances have methods, `value_from_message` which converts a `DateTimeMessage` to a `datetime`, and `value_to_message` which converts a `datetime` to a `DateTimeMessage`."]]],[]]