lib/adiwg/mdtranslator/readers/mdJson/modules/module_dateTime.rb in adiwg-mdtranslator-2.9.2 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_dateTime.rb in adiwg-mdtranslator-2.10.0

- old
+ new

@@ -1,54 +1,54 @@ # unpack dateTime # Reader - ADIwg JSON V1 to internal data structure # History: -# Stan Smith 2016-10-05 refactored for mdJson 2.0 -# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers -# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj) -# Stan Smith 2015-07-14 refactored to remove global namespace constants +# Stan Smith 2018-02-18 refactored error and warning messaging +# Stan Smith 2016-10-05 refactored for mdJson 2.0 +# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers +# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj) +# Stan Smith 2015-07-14 refactored to remove global namespace constants # Stan Smith 2013-12-11 original script require 'adiwg/mdtranslator/internal/module_dateTimeFun' module ADIWG - module Mdtranslator - module Readers - module MdJson + module Mdtranslator + module Readers + module MdJson - module DateTime + module DateTime - def self.unpack(sDateTime, responseObj) + def self.unpack(sDateTime, responseObj) - # return nil object if input is empty - if sDateTime == '' - responseObj[:readerExecutionMessages] << 'DateTime string is empty' - responseObj[:readerExecutionPass] = false - return nil - end + # return nil object if input is empty + if sDateTime == '' + responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: dateTime string is empty' + return nil + end - # instance classes needed in script - intMetadataClass = InternalMetadata.new - intDateTime = intMetadataClass.newDateTime + # instance classes needed in script + intMetadataClass = InternalMetadata.new + intDateTime = intMetadataClass.newDateTime - # dateTime - dateTime (required) - # if dateTimeFromString fails, [0] = nil; [1] = 'ERROR' - aDateTimeReturn = AdiwgDateTimeFun.dateTimeFromString(sDateTime) - if aDateTimeReturn[1] == 'ERROR' - responseObj[:readerExecutionMessages] << 'DateTime string is invalid' - responseObj[:readerExecutionPass] = false - return nil - else - intDateTime[:dateTime] = aDateTimeReturn[0] - intDateTime[:dateResolution] = aDateTimeReturn[1] - end + # dateTime - dateTime (required) + # if dateTimeFromString fails, [0] = nil; [1] = 'ERROR' + aDateTimeReturn = AdiwgDateTimeFun.dateTimeFromString(sDateTime) + if aDateTimeReturn[1] == 'ERROR' + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: dateTime string is invalid' + responseObj[:readerExecutionPass] = false + return nil + else + intDateTime[:dateTime] = aDateTimeReturn[0] + intDateTime[:dateResolution] = aDateTimeReturn[1] + end - return intDateTime + return intDateTime - end + end - end - end - end - end + + end + end + end end \ No newline at end of file