Sha256: 49c7cc9dc2355018174ad445113d65d898238a07f922ae448809abf0e57de9b6

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

# ISO <<Class>> CI_Date
# writer output in XML

# History:
# 	Stan Smith 2013-08-26 original script
# 	Stan Smith 2013-11-21 support for date or datetime
#   Stan Smith 2014-07-08 modify require statements to function in RubyGem structure

require 'module_dateTimeFun'
require 'code_dateType'

class CI_Date

	def initialize(xml)
		@xml = xml
	end

	def writeXML(hDate)

		# classes used
		dateTypeCode = CI_DateTypeCode.new(@xml)

		citDateTime = hDate[:dateTime]
		citDateRes = hDate[:dateResolution]
		citDateType = hDate[:dateType]

		@xml.tag!('gmd:CI_Date') do

			# date - date - required
			if citDateTime.nil?
				@xml.tag!('gmd:date',{'gco:nilReason'=>'missing'})
			else
				@xml.tag!('gmd:date') do

					if citDateRes.length > 3
						# if time, requires all time fields
						dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(citDateTime,'YMDhmsZ')
						@xml.tag!('gco:DateTime',dateStr)
					else
						dateStr = AdiwgDateTimeFun.stringDateFromDateTime(citDateTime,citDateRes)
						@xml.tag!('gco:Date',dateStr)
					end

				end

			end

			# date - date type - required
			if citDateType.nil?
				@xml.tag!('gmd:dateType',{'gco:nilReason'=>'missing'})
			else
				@xml.tag!('gmd:dateType') do
					dateTypeCode.writeXML(citDateType)
				end
			end
		end

	end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adiwg-mdtranslator-0.10.2 lib/adiwg/mdtranslator/writers/iso/classes/class_date.rb
adiwg-mdtranslator-0.9.0 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb
adiwg-mdtranslator-0.8.6 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb
adiwg-mdtranslator-0.8.5 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb
adiwg-mdtranslator-0.8.2 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb
adiwg-mdtranslator-0.8.1 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb
adiwg-mdtranslator-0.8.0 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb