Does uPython set ST_MTIME on file creation?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
tbnorth
Posts: 2
Joined: Fri May 11, 2018 9:19 pm

Does uPython set ST_MTIME on file creation?

Post by tbnorth » Fri May 11, 2018 9:31 pm

My test below (uPython 1.9.x) suggests not, just wanted to confirm, thanks.

>>> rtc.datetime()
(2018, 5, 11, 4, 21, 10, 39, 146)
>>> open('delme2.del', 'w')
<io.TextIOWrapper 2000e100>
>>> rtc.datetime((2010, 5, 11, 4, 21, 10, 39, 146))
>>> open('delme3.del', 'w')
<io.TextIOWrapper 2000e270>
>>> rtc.datetime()
(2010, 5, 11, 4, 21, 10, 48, 20)
>>> os.stat('delme2.del')
(32768, 0, 0, 0, 0, 0, 0, 12873600, 12873600, 12873600)
>>> os.stat('delme3.del')
(32768, 0, 0, 0, 0, 0, 0, 12873600, 12873600, 12873600)

User avatar
dhylands
Posts: 2756
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Does uPython set ST_MTIME on file creation?

Post by dhylands » Mon May 14, 2018 5:02 pm

Which board are you using?

The timestamps seem to be modified on a pyboard:

Code: Select all

MicroPython v1.9.3-521-gd6cf5c6 on 2018-04-23; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> rtc = pyb.RTC()
>>> rtc.datetime()
(2018, 5, 14, 1, 9, 57, 30, 200)
>>> open('delme2.del', 'w')
<io.TextIOWrapper 20003380>
>>> rtc.datetime((2010, 5, 11, 4, 21, 10, 39, 146))
>>> open('delme3.del', 'w')
<io.TextIOWrapper 20003a20>
>>> rtc.datetime()
(2010, 5, 11, 4, 21, 10, 54, 202)
>>> import os
>>> os.stat('delme2.del')
(32768, 0, 0, 0, 0, 0, 0, 579607056, 579607056, 579607056)
>>> os.stat('delme3.del')
(32768, 0, 0, 0, 0, 0, 0, 326927444, 326927444, 326927444)
>>> 

tbnorth
Posts: 2
Joined: Fri May 11, 2018 9:19 pm

Re: Does uPython set ST_MTIME on file creation?

Post by tbnorth » Mon May 14, 2018 9:34 pm

Odd, I'm using PyBoard 1.1, will try again copy pasting your code and report versions more carefully. Thanks.

Post Reply