Use Time#mktime_with_offset
This commit is contained in:
parent
f65d8bbbcc
commit
e4ad16b77c
2 changed files with 12 additions and 6 deletions
|
@ -509,15 +509,19 @@ describe "ExtendedDocument properties" do
|
|||
|
||||
describe 'and value is a string' do
|
||||
it 'parses the string' do
|
||||
@course.ends_at = '22:24'
|
||||
@course['ends_at'].hour.should eql(22)
|
||||
@course['ends_at'].min.should eql(24)
|
||||
t = Time.now
|
||||
@course.ends_at = t.strftime('%Y/%m/%d %H:%M:%S %z')
|
||||
@course['ends_at'].year.should eql(t.year)
|
||||
@course['ends_at'].month.should eql(t.month)
|
||||
@course['ends_at'].day.should eql(t.day)
|
||||
@course['ends_at'].hour.should eql(t.hour)
|
||||
@course['ends_at'].min.should eql(t.min)
|
||||
@course['ends_at'].sec.should eql(t.sec)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not typecast non-time values' do
|
||||
pending 'Time#parse is too permissive'
|
||||
@course.started_on = 'not-time'
|
||||
@course.ends_at = 'not-time'
|
||||
@course['ends_at'].should eql('not-time')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue