Function palmrs_database::time::is_palm_epoch
source · pub fn is_palm_epoch(timestamp: u32) -> bool
Expand description
Check if the given timestamp is using the “old Palm epoch”
This uses the incredibly simple heuristic of “is the top bit set?” – this works because the top bit will always be clear if we’re dealing with a signed integer (which is the case if the timestamp is using the UNIX epoch), and if the timestamp is using the old Palm epoch, the top bit will always be set if the timestamp is a date occurring after some time in 1972.
Palm OS definitely wasn’t around in 1972, making a Palm database containing a timestamp around this time period extremely unlikely to occur naturally (I mean, bit flipping could happen?), so this is a good enough measure of what timestamp format we’re using.
This is the same heuristic that palmdump, and many other Palm OS utilites, use for determining the timestamp format.