From ac102fb888e78e50f9a69b3b7364f90d4bf73eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marwan=20Rabb=C3=A2a?= Date: Sat, 3 Nov 2018 14:44:24 +0100 Subject: [PATCH] fix date issue --- spec/ssh2_spec.cr | 4 ++-- src/session.cr | 2 +- src/sftp/attributes.cr | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/ssh2_spec.cr b/spec/ssh2_spec.cr index b01f1a8..5fa3094 100644 --- a/spec/ssh2_spec.cr +++ b/spec/ssh2_spec.cr @@ -22,7 +22,7 @@ describe SSH2 do end it "should be able to scp transfer file" do - fn = "#{Time.now.epoch}.txt" + fn = "#{Time.now.to_unix}.txt" connect_ssh do |session| session.scp_send(fn, 0o0644, 12) do |ch| ch.puts "hello world" @@ -101,7 +101,7 @@ describe SSH2::SFTP do it "should be able to upload a file" do connect_ssh do |ssh| ssh.sftp_session do |sftp| - fn = "#{Time.now.epoch}_upload.txt" + fn = "#{Time.now.to_unix}_upload.txt" file = sftp.open(fn, "wc", 0o644) file.puts "hello world!" attrs = file.fstat diff --git a/src/session.cr b/src/session.cr index 3f0d64e..a5c8eea 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ class SSH2::Session # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now.epoch, atime = Time.now.epoch) + def scp_send(path, mode, size, mtime = Time.now.to_unix, atime = Time.now.to_unix) channel = scp_send(path, mode, size, mtime, atime) begin yield channel diff --git a/src/sftp/attributes.cr b/src/sftp/attributes.cr index 3cd128f..8daa642 100644 --- a/src/sftp/attributes.cr +++ b/src/sftp/attributes.cr @@ -52,7 +52,7 @@ class SSH2::SFTP::Attributes end def atime - Time.epoch(@stat.atime.to_i32) + Time.unix(@stat.atime.to_i32) end def atime=(v : Time)