rompy.swan.subcomponents.time.Time#
- pydantic model rompy.swan.subcomponents.time.Time[source]#
Time specification in SWAN.
[time]
Time is rendered in one of the following formats:
1: ISO-notation 19870530.153000
2: (as in HP compiler) ‘30-May-87 15:30:00’
3: (as in Lahey compiler) 05/30/87.15:30:00
4: 15:30:00
5: 87/05/30 15:30:00’
6: as in WAM 8705301530
Note
The time field can be specified as:
existing datetime object
int or float, assumed as Unix time, i.e. seconds (if >= -2e10 or <= 2e10) or milliseconds (if < -2e10 or > 2e10) since 1 January 1970.
ISO 8601 time string.
Examples
In [151]: from rompy.swan.subcomponents.time import Time In [152]: from datetime import datetime In [153]: time = Time(time=datetime(1990, 1, 1)) In [154]: print(time.render()) 19900101.000000 In [155]: time = Time(time="2012-01-01T00:00:00", tfmt=2) In [156]: print(time.render()) '01-Jan-12 00:00:00'
Show JSON schema
{ "title": "Time", "description": "Time specification in SWAN.\n\n.. code-block:: text\n\n [time]\n\nTime is rendered in one of the following formats:\n\n* 1: ISO-notation 19870530.153000\n* 2: (as in HP compiler) '30-May-87 15:30:00'\n* 3: (as in Lahey compiler) 05/30/87.15:30:00\n* 4: 15:30:00\n* 5: 87/05/30 15:30:00'\n* 6: as in WAM 8705301530\n\nNote\n----\nThe `time` field can be specified as:\n\n* existing datetime object\n* int or float, assumed as Unix time, i.e. seconds (if >= -2e10 or <= 2e10) or\n milliseconds (if < -2e10 or > 2e10) since 1 January 1970.\n* ISO 8601 time string.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.subcomponents.time import Time\n from datetime import datetime\n time = Time(time=datetime(1990, 1, 1))\n print(time.render())\n time = Time(time=\"2012-01-01T00:00:00\", tfmt=2)\n print(time.render())", "type": "object", "properties": { "model_type": { "default": "time", "description": "Model type discriminator", "enum": [ "time", "Time", "TIME" ], "title": "Model Type", "type": "string" }, "time": { "description": "Datetime specification", "format": "date-time", "title": "Time", "type": "string" }, "tfmt": { "anyOf": [ { "enum": [ 1, 2, 3, 4, 5, 6 ], "type": "integer" }, { "type": "string" } ], "default": 1, "description": "Format to render time specification", "title": "Tfmt" } }, "additionalProperties": false, "required": [ "time" ] }
- Fields:
- Validators:
- field model_type: Literal['time', 'Time', 'TIME'] = 'time'#
Model type discriminator
- field tfmt: Literal[1, 2, 3, 4, 5, 6] | str = 1#
Format to render time specification
- Validated by:
- field time: datetime [Required]#
Datetime specification