Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/time_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TimeObject *TimeObject::utc(Env *env, Value year, Optional<Value> month, Optiona
int seconds = timegm(&result->m_time);
result->m_mode = Mode::UTC;
result->m_integer = seconds;
if (subsec_arg) {
if (subsec_arg && !subsec_arg.value().is_nil()) {
auto subsec = subsec_arg.value();
if (subsec.is_integer()) {
auto integer = subsec.integer();
Expand Down
8 changes: 8 additions & 0 deletions test/natalie/time_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def time
t.nsec.should == 1
end
end

context 'with a nil microseconds argument' do
it 'returns a time with no subseconds' do
t = Time.utc(1970, 1, 1, 0, 0, 0, nil)
t.should be_an_instance_of(Time)
t.nsec.should == 0
end
end
end

describe '#+' do
Expand Down
Loading