Sha256: 0e96ab6553bdac3e3f9d3e1e3e5cd588b37d2759cd5cb2ad6d17b378dd8ef8de

Contents?: true

Size: 924 Bytes

Versions: 9

Compression:

Stored size: 924 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true
# encoding: UTF-8
# (c) ANB Andrew Bizyaev

require_relative '_tag'
require 'date'

module ExifTagger
  module Tag
    class TagDate < Tag
      private

      def get_from_raw
        @raw_values.each_value do |value|
          return value unless Tag.empty?(value)
        end
        EMPTY
      end

      def make_date_from(tag_date = '', tag_time = '')
        dcdt = %(#{tag_date} #{tag_time})
        DateTime.parse(dcdt.sub(/^(\d+):(\d+):/, '\1-\2-'))
      rescue ArgumentError
        EMPTY
      end

      def validate_type
        if @value.is_a?(String)
          validate_string_size(@value)

        elsif @value.is_a?(DateTime)

        else
          @errors << %(#{tag_name}: '#{@value}' is a wrong type \(#{@value.class}\))
        end
        return if @errors.empty?
        @value_invalid << @value
        @value = EMPTY
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
phtools-0.18.0 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.17.0 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.16.1 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.16.0 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.15.1 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.15.0 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.14.0 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.11.2 lib/phtools/exif_tagger/tags/_tag_date.rb
phtools-0.11.1 lib/phtools/exif_tagger/tags/_tag_date.rb