Skip to content

Instantly share code, notes, and snippets.

@Slackwise
Created April 4, 2013 15:00
Show Gist options
  • Save Slackwise/5311124 to your computer and use it in GitHub Desktop.
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.
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