Class: RDF::Literal::DateTime

Inherits:
RDF::Literal show all
Defined in:
lib/active_fedora.rb

Constant Summary collapse

ALTERNATIVE_FORMAT =
'%Y-%m-%dT%H:%M:%S'.freeze
DOT =
'.'.freeze
Z =
'Z'.freeze
EMPTY =
''.freeze

Instance Method Summary collapse

Instance Method Details

#to_sObject


26
27
28
29
30
31
32
33
# File 'lib/active_fedora.rb', line 26

def to_s
  @string ||= begin
    # Show nanoseconds but remove trailing zeros
    nano = @object.strftime('%N').sub(/0+\Z/, EMPTY)
    nano = DOT + nano unless nano.blank?
    @object.strftime(ALTERNATIVE_FORMAT) + nano + Z
  end
end