Example of time zone receiving "tz"

‘tz’ parameter can be received using Mathematical AND (&) Mathematical OR (|) bit operations.

For example, it is necessary to receive ‘tz’ parameter for the Azores time zone (-01:00), dst - none(0x08000000).


1. Mathematical AND should be applied to the Azores timezone using 0xf000ffff mask.

-3600 & 0xf000ffff
-268373520

2. Mathematical OR should be applied to the result using the mask corresponding to the dst.

-268373520 | 0x8000000
-134155792

tz=-134155792

Reverse operation

tz=-134155792

1) Mathematical AND should be applied to the ‘tz’ parameter using 0xffff mask.

-134155792 & 0xffff
61936

Only if the original tz value < 0 (it is in this example), then mathematical OR should be applied to the result using the mask 0xffff0000. If tz value > 0, the following step is not needed.

2) Mathematical OR should be applied to the result using the mask 0xffff0000.

61936 | 0xffff0000
-3600

timezone (-01:00) Azores.


tz=-134155792 in hex 0xf800f1f0

Value using 0x0fff0000 mask is dst. 0x08000000 - none.

Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam