Sha256: b486ccf35d4763b92227c88f7d340b3c0557c3386b4c3d868c697009acd1fc6b

Contents?: true

Size: 1.9 KB

Versions: 9

Compression:

Stored size: 1.9 KB

Contents

# FGDC <<Class>> DateSingle
# FGDC CSDGM writer output in XML

# History:
#  Stan Smith 2018-02-26 refactored error and warning messaging
#  Stan Smith 2018-01-19 convert ISO date formats to FGDC
#  Stan Smith 2017-11-23 original script

require 'adiwg/mdtranslator/internal/module_dateTimeFun'
require_relative '../fgdc_writer'

module ADIWG
   module Mdtranslator
      module Writers
         module Fgdc

            class DateSingle

               def initialize(xml, hResponseObj)
                  @xml = xml
                  @hResponseObj = hResponseObj
                  @NameSpace = ADIWG::Mdtranslator::Writers::Fgdc
               end

               def writeXML(hDate)

                  sDate = AdiwgDateTimeFun.stringDateFromDateTime(hDate[:dateTime], hDate[:dateResolution])
                  sTime = AdiwgDateTimeFun.stringTimeFromDateTime(hDate[:dateTime], hDate[:dateResolution])

                  # convert ISO date format to FGDC
                  sDate.gsub!(/[-]/,'')

                  # single date 9.1 (sngdate) - single date (required)
                  @xml.tag!('sngdate') do

                     # single date 9.1.1 (caldate) - calendar date
                     unless sDate == 'ERROR'
                        @xml.tag!('caldate', sDate)
                     end
                     if sDate == 'ERROR'
                        @NameSpace.issueError('single date is invalid',
                                              'multi date/time time period')
                     end

                     # single date 9.1.2 (time) - time
                     unless sTime == 'ERROR'
                        @xml.tag!('time', sTime)
                     end
                     if sTime == 'ERROR' && @hResponseObj[:writerShowTags]
                        @xml.tag!('time')
                     end

                  end

               end # writeXML
            end # SingleDate

         end
      end
   end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.14.2 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.14.1 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.14.0 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.13.3 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.13.2 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.13.1 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.13.0 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.12.0 lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb
adiwg-mdtranslator-2.12.0.pre lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb