Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
8175877a
Commit
8175877a
authored
Jan 10, 2016
by
Paul Sokolovsky
Browse files
unix/modtime: strftime(): Support 2nd argument, but as time_t value.
Instead of struct tm like structure, as required by CPython.
parent
fe6756aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
unix/modtime.c
View file @
8175877a
...
...
@@ -155,8 +155,14 @@ STATIC mp_obj_t mod_time_sleep_us(mp_obj_t arg) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_time_sleep_us_obj
,
mod_time_sleep_us
);
STATIC
mp_obj_t
mod_time_strftime
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
n_args
==
1
);
time_t
t
=
time
(
NULL
);
time_t
t
;
if
(
n_args
==
1
)
{
t
=
time
(
NULL
);
}
else
{
// CPython requires passing struct tm, but we allow to pass time_t
// (and don't support struct tm so far).
t
=
mp_obj_get_int
(
args
[
1
]);
}
struct
tm
*
tm
=
localtime
(
&
t
);
char
buf
[
32
];
size_t
sz
=
strftime
(
buf
,
sizeof
(
buf
),
mp_obj_str_get_str
(
args
[
0
]),
tm
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment