Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/xmltv/sites/upc.rb,
lib/xmltv/xmltv.rb,
lib/xmltv/sites/tvtoday.rb

Overview

require ‘uri’

Constant Summary collapse

Maanden =
[nil] + %w{ januari februari maart april mei juni juli augustus september oktober november december }
Dagen =
%w{ zondag maandag dinsdag woensdag donderdag vrijdag zaterdag }
Vandaag =
Date.today

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dutch(instring) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/xmltv/xmltv.rb', line 56

def self.dutch(instring)
  nu = today
  defjaar, defmaand, defdag, weekdag = nu.year, nu.month, nu.day, nu.wday
  jaar = maand = dag = nil
  string = instring.gsub(/[[:cntrl:][:punct:]]/, '').downcase
  string.split.each do |elem|
    case elem
      when /[[:alpha:]]+/
        if Maanden.include?(elem)
          maand = Maanden.index(elem)
          if maand < nu.month
            defjaar += 1
          end
        elsif Dagen.include?(elem)
          wd = Dagen.index(elem) - weekdag
          wd += 7 if wd < 0
          nu += wd
          defjaar, defmaand, defdag, weekdag = nu.year, nu.month, nu.day, nu.wday
        end
      when /[[:digit:]]+/
        ent = elem.to_i
        if ent <= 31
          dag = ent
        elsif ent > 1900
          jaar = ent
        end
    end
  end
  new(jaar || defjaar, maand || defmaand,dag || defdag)
end

.upcdate(string) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/xmltv/sites/upc.rb', line 8

def self.upcdate(string)
  if string == 'today'
    return Vandaag
  end
  rsl = dutch(string)
  rsl += 7 if rsl == Vandaag
  rsl
end

Instance Method Details

#germanObject



7
8
9
# File 'lib/xmltv/sites/tvtoday.rb', line 7

def german
  "#{day}.#{month}.#{year}"
end