Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/africompta/acqooxview.rb
Overview
We want a simple time-print class Time
def to_s
day.to_s + '/' + month.to_s
end
def to_ss
to_s + '/' + year.to_s
end
end
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_s(s) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/africompta/acqooxview.rb', line 32 def Date.from_s(s) # Do some date-magic, so that we can give either the day, day and month or # a complete date. The rest is filled up with todays date. date = [] if s.index('/') date = s.split('/') else date = s.split('-').reverse end da = Date.today d = [da.day, da.month, da.year] date += d.last(3 - date.size) if date[2].to_s.size > 2 date = Date.strptime(date.join('/'), '%d/%m/%Y') else date = Date.strptime(date.join('/'), '%d/%m/%y') end return date end |
Instance Method Details
#month_s ⇒ Object
19 20 21 22 |
# File 'lib/africompta/acqooxview.rb', line 19 def month_s %w(janvier février mars avril mai juin juillet août septembre octobre novembre décembre)[month-1] end |
#to_s_eu ⇒ Object
24 25 26 |
# File 'lib/africompta/acqooxview.rb', line 24 def to_s_eu strftime('%d/%m/%y') end |
#to_s_euy ⇒ Object
28 29 30 |
# File 'lib/africompta/acqooxview.rb', line 28 def to_s_euy strftime('%d/%m/%Y') end |