Created
April 4, 2013 15:00
-
-
Save Slackwise/5311124 to your computer and use it in GitHub Desktop.
Active Directory keeps track of time in 100 NS intervals (UTC) since January 1st, 1601.
Had to write this quick parsing method so I can work with AD exported data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateTime | |
def self.parse_ad_format(datetime) | |
datetime = datetime.to_i | |
datetime /= 10_000_000 # Convert nanoseconds to seconds | |
datetime -= 11_644_473_600 # Get the difference between 1600 and 1970 | |
strptime(datetime.to_s, '%s') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment