POSIX atime, mtime, ctime
This may help if you included the full script and its actual and expected outputs instead of REPL fragments.
import sys, os, stat, time def get_times(p): s = os.stat(p) return ( os.path.getatime(p), os.path.getmtime(p), os.path.getctime(p), s[stat.ST_ATIME], s[stat.ST_MTIME], s[stat.ST_CTIME], ) def main(p, delay=1): delay = float(delay) (a,b) = (1000000000, 1500000000) open(p,'w').close() print 'initial:' print get_times(p) for t in [ (a,a), (a,b), (b,a), (b,b) ]: print print 'test:', t os.utime(p,t) print get_times(p) time.sleep(delay) print get_times(p) main(*sys.argv[1:])
I get this on my 10.4 system with cd "$HOME" && python test.py tempfile 5 (system default Python 2.3.6 and MacPorts Python 2.6.4 both give the same result (of course, excluding start times and ctime)):
% python /tmp/test.py tempfile 5 initial: (1000000000.0, 1000000000.0, 1269629881.0, 1000000000, 1000000000, 1269629881) test: (1000000000, 1000000000) (1000000000.0, 1000000000.0, 1269629881.0, 1000000000, 1000000000, 1269629881) (1000000000.0, 1000000000.0, 1269629881.0, 1000000000, 1000000000, 1269629881) test: (1000000000, 1500000000) (1000000000.0, 1500000000.0, 1269629886.0, 1000000000, 1500000000, 1269629886) (1000000000.0, 1500000000.0, 1269629886.0, 1000000000, 1500000000, 1269629886) test: (1500000000, 1000000000) (1500000000.0, 1000000000.0, 1269629891.0, 1500000000, 1000000000, 1269629891) (1500000000.0, 1000000000.0, 1269629891.0, 1500000000, 1000000000, 1269629891) test: (1500000000, 1500000000) (1500000000.0, 1500000000.0, 1269629896.0, 1500000000, 1500000000, 1269629896) (1500000000.0, 1500000000.0, 1269629896.0, 1500000000, 1500000000, 1269629896)
That seems reasonable. I wonder what you get.
I heard that Spotlight can sometimes aggressively reset atime due to reindexing modified files. I would not expect it to reindex the file that utime () / utimes () just underwent, but I assume that this is possible. To fix Spotlight as a possible complication, use a file in a place that is not indexed by Spotlight (for example, / tmp / testfile).
Date Created in Finder
(shown as "Created:" in the "Get Information" Finder window)
If you have the developer tools installed, you can use /Developer/Tools/GetFileInfo to see the HFS creation file. I added the following lines after each line of print get_times(p) :
sys.stdout.flush() os.system('/Developer/Tools/GetFileInfo ' + p)
I also changed the iteration according to your initial description ( [ (a,b), (a,a), (b,a), (b,b) ] ).
The result now looks like this:
% rm /tmp/tempfile; python /tmp/test.py /tmp/tempfile 1 initial: (1269636574.0, 1269636574.0, 1269636574.0, 1269636574, 1269636574, 1269636574) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 03/26/2010 15:49:34 modified: 03/26/2010 15:49:34 test: (1000000000, 1500000000) (1000000000.0, 1500000000.0, 1269636574.0, 1000000000, 1500000000, 1269636574) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 03/26/2010 15:49:34 modified: 07/13/2017 21:40:00 (1000000000.0, 1500000000.0, 1269636574.0, 1000000000, 1500000000, 1269636574) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 03/26/2010 15:49:34 modified: 07/13/2017 21:40:00 test: (1000000000, 1000000000) (1000000000.0, 1000000000.0, 1269636576.0, 1000000000, 1000000000, 1269636576) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 09/08/2001 20:46:40 (1000000000.0, 1000000000.0, 1269636576.0, 1000000000, 1000000000, 1269636576) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 09/08/2001 20:46:40 test: (1500000000, 1000000000) (1500000000.0, 1000000000.0, 1269636577.0, 1500000000, 1000000000, 1269636577) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 09/08/2001 20:46:40 (1500000000.0, 1000000000.0, 1269636577.0, 1500000000, 1000000000, 1269636577) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 09/08/2001 20:46:40 test: (1500000000, 1500000000) (1500000000.0, 1500000000.0, 1269636578.0, 1500000000, 1500000000, 1269636578) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 07/13/2017 21:40:00 (1500000000.0, 1500000000.0, 1269636578.0, 1500000000, 1500000000, 1269636578) file: "/private/tmp/tempfile" type: "" creator: "" attributes: avbstclinmedz created: 09/08/2001 20:46:40 modified: 07/13/2017 21:40:00
This is similar to your observations from the Get Info window in Finder. My interpretation (confirmed by other experiments) is that the HFS creation file is updated using utime, but it only ever goes backward (never forward). If you want to upgrade the HFS creationDate to a newer value, you probably have to use the Mac API for this.
One more note: you may need to switch windows a bit to refresh the Get Info window. On my system, its display is not updated automatically unless I switch the windows to either the Get Info window or the Product Information window.