Skip to main content
Version: V3 (Ignition 8.3)

tamaki.mes.utils.convertTimezone

Description

Converts a date value to the specified timezone and returns it as a Date. Internally it formats the value in the target timezone using formatDate and then parses the result back into a Date. The timezone is resolved the same way as formatDate (explicit timezone, then the session timezone from self, then Etc/UTC).

Returns None if value is None.

Syntax

tamaki.mes.utils.convertTimezone(value, self=None, timezone="Etc/UTC")

Parameters

ParameterTypeNullableDescription
valueNumber or DateTrueThe date/time value to convert: milliseconds (int/long) or a java.util.Date. Returns None if None.
selfObjectTrueThe component self, used to infer the session timezone when timezone is not provided. Defaults to None.
timezoneStringTrueAn explicit timezone ID. Defaults to "Etc/UTC".

Returns

A Date in the target timezone, or None if value is None.

Code Examples

# In a binding script transform: convert a date to the session (or explicit) timezone
return tamaki.mes.utils.convertTimezone(value)