Class: Ldapter::Syntaxes::GeneralizedTime
- Inherits:
-
Abstract
- Object
- Abstract
- Ldapter::Syntaxes::GeneralizedTime
- Defined in:
- lib/ldapter/syntaxes.rb
Overview
LDAP timestamps look like YYYYmmddHHMMSS.uuuuuuZ.
Instance Method Summary (collapse)
Methods inherited from Abstract
Constructor Details
This class inherits a constructor from Ldapter::Syntaxes::Abstract
Instance Method Details
- (Object) format(time)
158 159 160 |
# File 'lib/ldapter/syntaxes.rb', line 158 def format(time) time.utc.strftime("%Y%m%d%H%M%S")+".%06dZ" % [time.usec/100_000] end |
- (Object) parse(string)
150 151 152 153 154 155 156 157 |
# File 'lib/ldapter/syntaxes.rb', line 150 def parse(string) require 'time' parseable = string.sub(/(\.\d+)(\w)$/,'\\2') Time.parse(parseable)+$1.to_f rescue ArgumentError require 'date' DateTime.parse(parseable) end |