◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
3 changes: 2 additions & 1 deletion Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ def test_sleep(self):
self.assertRaises(ValueError, time.sleep, -1)
time.sleep(1.2)

@unittest.skip("TODO: RUSTPYTHON, thread 'main' panicked at 'a Display implementation returned an error unexpectedly: Error'")
def test_strftime(self):
tt = time.gmtime(self.t)
for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I',
Expand Down
5 changes: 5 additions & 0 deletions extra_tests/snippets/stdlib_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def __init__(self, offset, name):
assert_raises(NotImplementedError, ne.utcoffset, dt)
assert_raises(NotImplementedError, ne.dst, dt)

# XXX: bug #1302
# def test_normal(self):
#fo = FixedOffset(3, "Three")
Expand Down
12 changes: 11 additions & 1 deletion vm/src/stdlib/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,18 @@ mod time {

#[pyfunction]
fn strftime(format: PyStrRef, t: OptionalArg<PyStructTime>, vm: &VirtualMachine) -> PyResult {
let instant = t.naive_or_local(vm)?;
let formatted_time = instant.format(format.as_str()).to_string();
Ok(vm.ctx.new_str(formatted_time).into())
}

Expand Down
Toggle all file notes Toggle all file annotations