sample_localize - bruno-beloff/scs_analysis GitHub Wiki

docs > software repositories > scs_analysis > commands > time


DESCRIPTION

The sample_localize utility is used to shift the rec datetime field of each input document from its current offset to the offset determined by the given timezone.

When the transform is applied, the the date / time is shifted, and the UTC offset field is altered accordingly. Thus, the resulting localised datetime represents the same point in global history, presented for a alternative UTC offset.

In most cases, the UTC offset of a timezone is dependent on daylight saving time. The sample_localize utility is sensitive to this - the adjustment to the UTC offset of each document's rec field is dependent on its specific date / time value. Thus, UTC offsets are not the same thing as timezones! It is always safe to shift from UTC to a timezone, but sifting to a subsequent timezone can have unexpected results, particularly on daylight saving time boundaries.

The sample_localize utility halts on input lines which have no datetime field, or a datetime field with a malformed ISO 8601 datetime.

Note that the timezone of a South Coast Science device is normally reported on its status topic.

SYNOPSIS

sample_localize.py { -z | -t TIMEZONE_NAME [-i ISO_PATH] [-v]

Options
-h, --help show this help message and exit
-z, --zones list the available timezone names to stderr
-t TIMEZONE, --timezone=TIMEZONE timezone for localization
-i ISO, --iso-path=ISO path for ISO 8601 datetime input (default 'rec')
-v, --verbose report narrative to stderr

EXAMPLES

aws_topic_history.py -s 2023-03-26T00:50:00Z -e 2023-03-26T01:10:00Z south-coast-science-demo/brighton-urban/loc/1/climate | sample_localize.py -v -t Europe/London

DOCUMENT EXAMPLE - INPUT

{"val": {"hmd": 73.6, "tmp": 12.0, "bar": {"pA": 99.272}}, "rec": "2023-03-26T01:00:09Z", "ver": 1.0, "tag": "scs-bgx-570"}

DOCUMENT EXAMPLE - OUTPUT

{"val": {"hmd": 73.6, "tmp": 12.0, "bar": {"pA": 99.272}}, "rec": "2023-03-26T02:00:09+01:00", "ver": 1.0, "tag": "scs-bgx-570"}

SEE ALSO

scs_analysis/sample_iso_8601
scs_analysis/sample_time_shift

RESOURCES

Data formats
ISO_8601
World Timezone Definitions for Python