Class ActiveLdap::Schema::Syntaxes::GeneralizedTime
In: lib/active_ldap/schema/syntaxes.rb
Parent: Base
Error DeleteError LdapError AdapterNotSpecified OperationNotPermitted RequiredAttributeMissed LdifInvalid AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Base DistinguishedName Ldif Reloadable::Deprecated Reloadable::Subclasses Enumerable Collection StandardError Children HasMany HasManyWrap BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText Parser GetTextSupport Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap Normalize ActiveRecord::Callbacks ActiveRecord::Validations Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/ldif.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations ClassMethods HumanReadable lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/has_many.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb HasManyUtils Association ClassMethods Tree Acts Common LDIF Delete Find Update Operations lib/active_ldap/get_text/parser.rb GetText ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb Adapter GetTextSupport Normalize ClassMethods Attributes Escape Callbacks ClassMethods ObjectClass Helper Validations ClassMethods Connection GetTextFallback Populate Salt UserPassword ActiveLdap dot/m_40_0.png

Methods

Public Instance methods

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 178
178:         def normalize_value(value)
179:           if value.is_a?(Time)
180:             normalized_value = value.strftime("%Y%m%d%H%M%S")
181:             if value.gmt?
182:               normalized_value + "Z"
183:             else
184:               normalized_value + ("%+03d%02d" % value.gmtoff.divmod(3600))
185:             end
186:           else
187:             value
188:           end
189:         end

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 169
169:         def type_cast(value)
170:           return value if value.nil? or value.is_a?(Time)
171:           begin
172:             Time.parse(value)
173:           rescue ArgumentError
174:             value
175:           end
176:         end

Private Instance methods

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 192
192:         def validate_normalized_value(value, original_value)
193:           match_data = /\A
194:                          (\d{4,4})?
195:                          (\d{2,2})?
196:                          (\d{2,2})?
197:                          (\d{2,2})?
198:                          (\d{2,2})?
199:                          (\d{2,2}(?:[,.]\d+)?)?
200:                          ([+-]\d{4,4}|Z)?
201:                         \z/x.match(value)
202:           if match_data
203:             year, month, day, hour, minute, second, time_zone =
204:               match_data.to_a[1..-1]
205:             missing_components = []
206:             %w(year month day hour minute).each do |component|
207:               missing_components << component unless eval(component)
208:             end
209:             if missing_components.empty?
210:               nil
211:             else
212:               params = [original_value.inspect, missing_components.join(", ")]
213:               _("%s has missing components: %s") % params
214:             end
215:           else
216:             _("%s is invalid time format") % original_value.inspect
217:           end
218:         end

[Validate]