Skip to content

Commit

Permalink
base the file's new utime on current UTC time (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrg0029 authored and willmcgugan committed Jun 2, 2019
1 parent e07d82a commit e2e3be1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import unittest
import tempfile
import shutil
import datetime
import calendar

from six import PY2

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

def _delay_file_utime(self, filepath, delta_sec=None):
import calendar
from datetime import datetime

file_access_mod_time = (
int(calendar.timegm(datetime.now().timetuple())) + delta_sec
)
times = (file_access_mod_time, file_access_mod_time)
def _delay_file_utime(self, filepath, delta_sec):
utcnow = datetime.datetime.utcnow()
unix_timestamp = calendar.timegm(utcnow.timetuple())
times = unix_timestamp + delta_sec, unix_timestamp + delta_sec
os.utime(filepath, times)

def test_copy_file_if_newer_same_fs(self):
Expand Down

0 comments on commit e2e3be1

Please sign in to comment.