Class: Rubyvis::Format::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyvis/format/date.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Date

Returns a new instance of Date.



6
7
8
9
# File 'lib/rubyvis/format/date.rb', line 6

def initialize(pattern)
  @pattern=pattern
  #@pad=Rubyvis::Format.pad
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



5
6
7
# File 'lib/rubyvis/format/date.rb', line 5

def pattern
  @pattern
end

Instance Method Details

#format(d) ⇒ Object

@pad=Rubyvis::Format.pad



10
11
12
# File 'lib/rubyvis/format/date.rb', line 10

def format(d)
  d.strftime(pattern)
end

#format_lambdaObject



13
14
15
16
17
18
# File 'lib/rubyvis/format/date.rb', line 13

def format_lambda
  pat=pattern
  lambda {|d| 
    d.strftime(pat)
  }
end

#parse(s) ⇒ Object



19
20
21
22
# File 'lib/rubyvis/format/date.rb', line 19

def parse(s)
  time=::DateTime.strptime(s, pattern)
  Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec, 0)
end