Reputation: 429
I've searched for an example to convert WINAPI FILETIME values into UNIX time_t (for a new Golang project) and found an example in Python.
Although I coded many in Python in the past I do not know the <<=
and |=
syntax in that example and Googles is not able to produce usable results for these search statements.
Could someone explain to me what they do?
import datetime
_FILETIME_null_date = datetime.datetime(1601, 1, 1, 0, 0, 0)
def FiletimeToDateTime(ft):
timestamp = ft.dwHighDateTime
timestamp <<= 32
timestamp |= ft.dwLowDateTime
return _FILETIME_null_date + datetime.timedelta(microseconds=timestamp/10)
Upvotes: 1
Views: 56
Reputation: 15310
This is taken from C. It is the '<<' or '|' operator (bitwise shift left and bitwise or, respectively) plus the assignment operator:
a <<= b
Is the same as
a = a << b
Similarly for |=.
Upvotes: 3
Reputation: 36043
They are the augmented assignment versions of the bit shift operator <<
and the bitwise or |
, just like +=
is the augmented +
, so:
timestamp <<= 32
is the equivalent of
timestamp = timestamp << 32
Upvotes: 2