Class: Binenc::Java::ASN1DateTime

Inherits:
Object
  • Object
show all
Includes:
ASN1Object
Defined in:
lib/binenc/asn1_engine/object/datetime.rb

Instance Attribute Summary

Attributes included from ASN1Object

#value

Instance Method Summary collapse

Methods included from ASN1Object

decode, #initialize

Methods included from DataConversion

#from_b64, #from_hex, included, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str

Instance Method Details

#encoded(binary = true) ⇒ Object

Raises:

  • (BinencEngineException)


9
10
11
12
13
14
15
16
17
# File 'lib/binenc/asn1_engine/object/datetime.rb', line 9

def encoded(binary = true)
  raise BinencEngineException, "Given value is not a Time object. #{@value.class}" if not (@value.is_a?(Time) or @value.is_a?(java.util.Date))
  obj = org.bouncycastle.asn1.DERGeneralizedTime.new(@value)
  if binary
    obj.encoded
  else
    obj
  end
end

#is_equal?(val) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/binenc/asn1_engine/object/datetime.rb', line 19

def is_equal?(val)

  case val
  when Integer
    @value.time.to_i == val
  when Time
    @value.time.to_i == val.to_i*1000
  else
    @value == val
  end
  
end