@@ -358,30 +358,33 @@ defmodule File do
358358
359359 @ doc """
360360 Updates modification time (mtime) and access time (atime) of
361- the given file. File is created if it doesn’t exist.
361+ the given file.
362+
363+ File is created if it doesn’t exist. Requires datetime in UTC.
362364 """
363365 @ spec touch ( Path . t , :calendar . datetime ) :: :ok | { :error , posix }
364- def touch ( path , time \\ :calendar . local_time ) do
366+ def touch ( path , time \\ :calendar . universal_time ) do
365367 path = IO . chardata_to_string ( path )
366- case F . change_time ( path , time ) do
368+ case :elixir_utils . change_universal_time ( path , time ) do
367369 { :error , :enoent } -> touch_new ( path , time )
368370 other -> other
369371 end
370372 end
371373
372374 defp touch_new ( path , time ) do
373375 case write ( path , "" , [ :append ] ) do
374- :ok -> F . change_time ( path , time )
376+ :ok -> :elixir_utils . change_universal_time ( path , time )
375377 { :error , _reason } = error -> error
376378 end
377379 end
378380
379381 @ doc """
380382 Same as `touch/2` but raises an exception if it fails.
381- Returns `:ok` otherwise.
383+
384+ Returns `:ok` otherwise. Requires datetime in UTC.
382385 """
383386 @ spec touch! ( Path . t , :calendar . datetime ) :: :ok | no_return
384- def touch! ( path , time \\ :calendar . local_time ) do
387+ def touch! ( path , time \\ :calendar . universal_time ) do
385388 case touch ( path , time ) do
386389 :ok -> :ok
387390 { :error , reason } ->
@@ -451,16 +454,16 @@ defmodule File do
451454 It returns `:ok` in case of success, returns `{:error, reason}` otherwise
452455
453456 Note: The command `mv` in Unix systems behaves differently depending
454- if `source` is a file and the `destination` is an existing directory.
455- We have chosen to explicitly disallow this behaviour.
457+ if `source` is a file and the `destination` is an existing directory.
458+ We have chosen to explicitly disallow this behaviour.
456459
457460 ## Examples
458461
459462 # Rename file "a.txt" to "b.txt"
460463 File.rename "a.txt", "b.txt"
461464
462465 # Rename directory "samples" to "tmp"
463- File.rename "samples", "tmp"
466+ File.rename "samples", "tmp"
464467 """
465468 @ spec rename ( Path . t , Path . t ) :: :ok | { :error , posix }
466469 def rename ( source , destination ) do
@@ -1198,19 +1201,19 @@ defmodule File do
11981201 is specified. This means any data streamed into the file must be
11991202 converted to `iodata` type. If you pass `[:utf8]` in the modes parameter,
12001203 the underlying stream will use `IO.write/2` and the `String.Chars` protocol
1201- to convert the data. See `IO.binwrite/2` and `IO.write/2` .
1204+ to convert the data. See `IO.binwrite/2` and `IO.write/2` .
12021205
12031206 One may also consider passing the `:delayed_write` option if the stream
12041207 is meant to be written to under a tight loop.
12051208
12061209 ## Examples
1207-
1210+
12081211 # Read in 2048 byte chunks rather than lines
12091212 File.stream!("./test/test.data", [], 2048)
12101213 #=> %File.Stream{line_or_bytes: 2048, modes: [:raw, :read_ahead, :binary],
12111214 #=> path: "./test/test.data", raw: true}
12121215
1213- See `Stream.run/1` for an example of streaming into a file.
1216+ See `Stream.run/1` for an example of streaming into a file.
12141217
12151218 """
12161219 def stream! ( path , modes \\ [ ] , line_or_bytes \\ :line ) do
0 commit comments