Class: RDF::Literal::DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#to_sObject



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

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