Class ActiveLdap::Schema::Syntaxes::GeneralizedTime
In: lib/active_ldap/schema/syntaxes.rb
Parent: Base
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations 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 Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb 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 Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_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 198
198:         def normalize_value(value)
199:           if value.is_a?(Time)
200:             normalized_value = value.strftime("%Y%m%d%H%M%S")
201:             if value.gmt?
202:               normalized_value + "Z"
203:             else
204:               normalized_value + ("%+03d%02d" % value.gmtoff.divmod(3600))
205:             end
206:           else
207:             value
208:           end
209:         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:             Time.send(:make_time,
191:                       year, month, day, hour, minute, second, fraction,
192:                       time_zone, Time.now)
193:           else
194:             value
195:           end
196:         end

Private Instance methods

[Source]

     # File lib/active_ldap/schema/syntaxes.rb, line 212
212:         def validate_normalized_value(value, original_value)
213:           match_data = FORMAT.match(value)
214:           if match_data
215:             year, month, day, hour, minute, second, fraction, time_zone =
216:               match_data.to_a[1..-1]
217:             missing_components = []
218:             %w(year month day hour minute second).each do |component|
219:               missing_components << component unless eval(component)
220:             end
221:             if missing_components.empty?
222:               nil
223:             else
224:               params = [original_value.inspect, missing_components.join(", ")]
225:               _("%s has missing components: %s") % params
226:             end
227:           else
228:             _("%s is invalid time format") % original_value.inspect
229:           end
230:         end

[Validate]