Skip to content

Commit e2e3be1

Browse files
mrg0029willmcgugan
authored andcommitted
base the file's new utime on current UTC time (#286)
1 parent e07d82a commit e2e3be1

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/test_copy.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import unittest
77
import tempfile
88
import shutil
9-
import datetime
9+
import calendar
10+
1011
from six import PY2
1112

1213
import fs.copy
@@ -116,14 +117,10 @@ def _write_file(self, filepath, write_chars=1024):
116117
f.write("1" * write_chars)
117118
return filepath
118119

119-
def _delay_file_utime(self, filepath, delta_sec=None):
120-
import calendar
121-
from datetime import datetime
122-
123-
file_access_mod_time = (
124-
int(calendar.timegm(datetime.now().timetuple())) + delta_sec
125-
)
126-
times = (file_access_mod_time, file_access_mod_time)
120+
def _delay_file_utime(self, filepath, delta_sec):
121+
utcnow = datetime.datetime.utcnow()
122+
unix_timestamp = calendar.timegm(utcnow.timetuple())
123+
times = unix_timestamp + delta_sec, unix_timestamp + delta_sec
127124
os.utime(filepath, times)
128125

129126
def test_copy_file_if_newer_same_fs(self):

0 commit comments

Comments
 (0)