Add timezone to DateTime format

This commit is contained in:
Guillaume DOTT 2013-09-06 10:39:14 +02:00
parent 548e5cd4cd
commit be87792382
3 changed files with 3 additions and 3 deletions

View File

@ -66,7 +66,7 @@ module Biju
rule(empty_string: simple(:empty_string)) { '' }
rule(int: simple(:int)) { int.to_i }
rule(string: simple(:string)) { string.to_s }
rule(datetime: simple(:datetime)) { DateTime.strptime(datetime.to_s, "%y/%m/%d,%T") }
rule(datetime: simple(:datetime)) { DateTime.strptime(datetime.to_s, "%y/%m/%d,%T%Z") }
rule(array: subtree(:array)) { array }
rule(status: simple(:status)) { { status: status } }

View File

@ -21,7 +21,7 @@ module Biju
def datetime=(arg)
@datetime = case arg
when String
DateTime.strptime(arg, "%y/%m/%d,%T")
DateTime.strptime(arg, "%y/%m/%d,%T%Z")
when DateTime
arg
else

View File

@ -12,6 +12,6 @@ describe Biju::Sms do
its(:id) { should eq(1) }
its(:phone_number) { should eq("144") }
its(:datetime) { should eq(DateTime.new(2011, 7, 28, 15, 34, 8)) }
its(:datetime) { should eq(DateTime.new(2011, 7, 28, 15, 34, 8, '-12')) }
its(:message) { should eq("Some text here") }
end