Module: BlackStack::DateTime::Misc

Defined in:
lib/functions.rb

Overview


Miscelaneous


Class Method Summary collapse

Class Method Details

.datetime_values_check(year, month, day, hour, minute, second) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/functions.rb', line 20

def self.datetime_values_check(year,month,day,hour,minute,second)
  if (year.to_i<1900 || year.to_i>=2100)
    return false
  end

  if (month.to_i<1 || month.to_i>12)
    return false
  end

  # TODO: Considerar la cantidad de dias de cada mes, y los anios biciestos. Buscar alguna funcion existente.
  if (day.to_i<1 || day.to_i>31)
    return false
  end

  if (hour.to_i<0 || hour.to_i>23)
    return false
  end

  if (minute.to_i<0 || minute.to_i>59)
    return false
  end

  if (second.to_i<0 || second.to_i>59)
    return false
  end

  return true
end