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
EMPTY =
''.freeze
TIMEZONE_FORMAT =
'%:z'.freeze

Instance Method Summary collapse

Instance Method Details

#to_sObject



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

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 + @object.strftime(TIMEZONE_FORMAT)
  end
end