#!/usr/bin/env python
# touch.py - /bin/touch that writes the LLVM epoch -*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ----------------------------------------------------------------------------
#
# Like /bin/touch, but takes a time using the LLVM epoch.
#
# ----------------------------------------------------------------------------

import os
import sys

assert len(sys.argv) >= 2
timeVal = int(sys.argv[1])

# offset between Unix and LLVM epochs
timeVal += 946684800

# Update the output file mtime, or create it if necessary.
# From http://stackoverflow.com/a/1160227.
for outputFile in sys.argv[1:]:
    with open(outputFile, 'a'):
        os.utime(outputFile, (timeVal, timeVal))

#!/usr/bin/env python
# touch.py - /bin/touch that writes the LLVM epoch -*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ----------------------------------------------------------------------------
#
# Like /bin/touch, but takes a time using the system_clock epoch.
#
# ----------------------------------------------------------------------------

import os
import sys

assert len(sys.argv) >= 2
timeVal = int(sys.argv[1])

# Update the output file mtime, or create it if necessary.
# From http://stackoverflow.com/a/1160227.
for outputFile in sys.argv[1:]:
    with open(outputFile, 'a'):
        os.utime(outputFile, (timeVal, timeVal))

Fix tests for file timestamps to drop the LLVM epoch offset.
Fix tests for file timestamps to drop the LLVM epoch offset.

Now that Swift is not using LLVM's TimeValue (564fc6f2 and previous commit)
there is no offset from the system_clock epoch. The offset could be added
into the tests that use touch.py (so the times would not be back in 1984)
but I decided not to do that to avoid merge conflicts in the test files.
