Class ActiveLdap::Schema::Syntaxes::GeneralizedTime
In: lib/active_ldap/schema/syntaxes.rb
Parent: Base
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid DistinguishedNameNotSetError EntryNotFound LdapError SaveError StrongAuthenticationRequired NotImplemented AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] Base DistinguishedName Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Normalizable Common Find LDIF Delete Update ActiveRecord::Callbacks GetText Parser Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport ActiveRecord::Validations Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command ClassMethods Normalizable Attributes Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Configuration ClassMethods ObjectClass ClassMethods Callbacks lib/active_ldap/get_text/parser.rb GetText lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb lib/active_ldap/adapter/jndi.rb Adapter Validations GetTextFallback Helper ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_46_0.png

Methods

Constants

FORMAT = /\A (\d{4,4})? (\d{2,2})? (\d{2,2})? (\d{2,2})? (\d{2,2})? (\d{2,2})? ([,.]\d+)? ([+-]\d{4,4}|Z)? \z/x

Public Instance methods

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 210
210:         def normalize_value(value)
211:           if value.is_a?(Time)
212:             normalized_value = value.strftime("%Y%m%d%H%M%S")
213:             if value.gmt?
214:               normalized_value + "Z"
215:             else
216:               normalized_value + ("%+03d%02d" % value.gmtoff.divmod(3600))
217:             end
218:           else
219:             value
220:           end
221:         end

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 179
179:         def type_cast(value)
180:           return value if value.nil? or value.is_a?(Time)
181:           match_data = FORMAT.match(value)
182:           if match_data
183:             required_components = match_data.to_a[1, 6]
184:             return value if required_components.any?(&:nil?)
185:             year, month, day, hour, minute, second =
186:               required_components.collect(&:to_i)
187:             fraction = match_data[-2]
188:             fraction = fraction.to_f if fraction
189:             time_zone = match_data[-1]
190:             begin
191:               Time.send(:make_time,
192:                         year, month, day, hour, minute, second, fraction,
193:                         time_zone, Time.now)
194:             rescue ArgumentError
195:               raise if year >= 1700
196:               out_of_range_messages = ["argument out of range",
197:                                        "time out of range"]
198:               raise unless out_of_range_messages.include?($!.message)
199:               Time.at(0)
200:             rescue RangeError
201:               raise if year >= 1700
202:               raise if $!.message != "bignum too big to convert into `long'"
203:               Time.at(0)
204:             end
205:           else
206:             value
207:           end
208:         end

Private Instance methods

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 224
224:         def validate_normalized_value(value, original_value)
225:           match_data = FORMAT.match(value)
226:           if match_data
227:             year, month, day, hour, minute, second, fraction, time_zone =
228:               match_data.to_a[1..-1]
229:             missing_components = []
230:             %w(year month day hour minute second).each do |component|
231:               missing_components << component unless eval(component)
232:             end
233:             if missing_components.empty?
234:               nil
235:             else
236:               params = [original_value.inspect, missing_components.join(", ")]
237:               _("%s has missing components: %s") % params
238:             end
239:           else
240:             _("%s is invalid time format") % original_value.inspect
241:           end
242:         end

[Validate]