Correcting Epoch time strangeness

I was accessing data from an and made an (EDA). One irregularity that I noticed, was that the epoch time was off by roughly forty-six thousand years! How the time came to be so long, could stem from the “dot” had somehow been removed.A hack work-around was to convert the epoch time to a string variable, chop off the last three digits, insert a decimal dot, and glue the string back together as an float. This way I was able to get the correct value. As far as I can see, this way of doing it, is safe for values up to the year 9999, possibly more.

__author__ = 'Miklas Njor - iAmGoldenboy -'__datum__ = '10/03/16'import timeoriginalEpoch = 1455624188738def correctingEpoch(epochTimeInt): insertDecimal = "{}.{}".format( str(originalEpoch)[:10], str(originalEpoch)[10:]) return float(insertDecimal)# Testing# The original epoch stringprint("Epoch Original: ", originalEpoch)# Which is off by 46.000 years!print("Epoch Converted: ", time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime( originalEpoch) ) )# proving that it must be the decimal that was removedprint("Epoch w. decimal: ", time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime( 1455624188.738 ) ))# Using the function correctingEpoch to get the correct time.print("Epoch Corrected: ", time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime( correctingEpoch(originalEpoch) ) ))
Læs også  How to add collapsible comment form to your wordpress blog
%d bloggers like this:

Ved at bruge hjemmesiden accepterer du brugen af cookies mere information

Cookie indstillingerne på denne hjemmeside er aktiveret for at give dig den bedste oplevelse. Hvis du fortsætter med at bruge hjemmesiden uden at ændre dine cookie indstillinger eller du klikker Accepter herunder, betragtes dette som din accept