Class: LibTAD::TADTime::TADTime

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

Overview

Information about date, time and timezone.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ TADTime

Returns a new instance of TADTime.



23
24
25
26
27
# File 'lib/types/time/time.rb', line 23

def initialize(hash)
  @iso = hash.fetch('iso', nil)
  @datetime = TADDateTime.new.from_json hash['datetime'] unless !hash.key?('datetime')
  @timezone = TADTimeZone.new hash['timezone'] unless !hash.key?('timezone')
end

Instance Attribute Details

#datetimeDateTime (readonly)

Date and time, split up into components.

Returns:

  • (DateTime)


17
18
19
# File 'lib/types/time/time.rb', line 17

def datetime
  @datetime
end

#isoString (readonly)

ISO representation of date and time, time zone included (@see dev-test.timeanddate.com/docs/external-references#ISO8601 ISO8601) if different from UTC. If time is not applicable, only the date is shown.

Example: 2011-06-08T09:18:16+02:00 Example: 2011-06-08T07:18:16 (UTC time) Example: 2011-06-08 (only date)

Returns:

  • (String)


13
14
15
# File 'lib/types/time/time.rb', line 13

def iso
  @iso
end

#timezoneTimeZone (readonly)

Timezone information.

Returns:

  • (TimeZone)


21
22
23
# File 'lib/types/time/time.rb', line 21

def timezone
  @timezone
end