Topic "Problem with Daylight saving time"

Author Message
osram
[View user's profile]

Joined: 2012-04-18
Posts: 3
I've been using the .Net assembly (5.0.6 beta) and powershell to write a simple download script.
The script logs in, traverses the directory tree and downloads all files that have been modified since last time.
It connect to a SFTP-server running on centos. When I use the WinSCP gui to connect, all timestamps are reported correctly (using "adjust remote timestamp to local conventions").

When using my script however the time of the remote files lastWrite is pushed one hour back in time.
I've been reading a lot on the forum and in the documentations and I guess that my problem is related to:
http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
http://winscp.net/eng/docs/timestamp.

I've tested to set ConsiderDST to both 0 and 1 and using it with and without the preserve flag. Setting it to 0 makes the time shift 2hours back in time and setting it to 1 makes the shift 1hour.
My connection code is straight forward.
Code:

    # Setup session options
    $options = New-Object WinSCP.SessionOptions
    $options.Protocol = [WinSCP.Protocol]::sFtp
    $options.HostName = $remoteServer
    $options.UserName = $remoteUser
    $options.Password = $remotePassword
    $options.SshHostKey = "ssh-rsa 2048 9e:8a:5e:3b:e3:85:cd:97:46:5a:1e:53:2c:c0:b2:87"
    $options.AddRawSettings("PreserveTime", 1);
    $options.AddRawSettings("ConsiderDST", 0);
   
    $session = New-Object WinSCP.Session
    try {
         # Connect to SFTP server
    write-host "Connecting to SFTP server at " $options.HostName
         $session.Open($options)
         ....
    }

I've also tested:
Code:

    #Dissable defaultConfig and load ini file that works with GUI
    $session.DefaultConfiguration=$FALSE;
    $session.iniFilePath="./winscp.ini";

    #Put the flags as exec arguments
    $session.AdditionalExecutableArguments="/ConsiderDST=0 /PreserveTime=1"

Whatever I do the times are haunting me and I'm starting to feel that there might be some kind of bug in play as I can connect to the server just fine using the WinSCP GUI client but not with the .Net assembly.

Any help would be appreciated.
/Lukas
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
1) What DST setting are you using in the GUI?
2) Please post a screenshot of GUI with some test directory as evidence of correct timestamps
3) Run
winscp.com /xmllog=log.xml /command "open <your session>" "ls <test path>" exit
4) Post log.xml
Thanks
_________________
Martin Prikryl
osram
[View user's profile]

Joined: 2012-04-18
Posts: 3
Server time/timezone:
Code:
[lujo@oracle ~]$ date
Fri Apr 20 16:20:03 CEST 2012


Server ls:
Code:
[lujo@oracle ~]$ sudo ls /home/ftpuser/ -l
total 0
-rw-r--r--. 1 root root 0 Apr 20 15:53 test.test


Code for testclient:
Code:
$localDir = ""
$remoteDir = "./"
$remoteUser = "ftpuser"
$remotePassword = "ftp"
$remoteServer = "192.168.10.39"
$remoteKey = "ssh-rsa 2048 9e:8a:5e:3b:e3:85:cd:97:46:5a:1e:53:2c:c0:b2:87"

# Load .NET components
add-type -Path "WinSCP.dll"

try {
    # Setup session options
    $options = New-Object WinSCP.SessionOptions
    $options.Protocol = [WinSCP.Protocol]::sftp
    $options.HostName = $remoteServer
    $options.UserName = $remoteUser
    $options.Password = $remotePassword
    $options.SshHostKey = "ssh-rsa 2048 9e:8a:5e:3b:e3:85:cd:97:46:5a:1e:53:2c:c0:b2:87"
    $options.AddRawSettings("PreserveTime", 1)
    $options.AddRawSettings("ConsiderDST",1)
    $session = New-Object WinSCP.Session
   
   try {
        $session.Open($options)
        $dir = $session.GetFileInfo($remoteDir)
        $ls = $session.ListDirectory($dir)
        write-host "Name `t`t LastWriteTime"
        foreach ($file in $ls.Files) {
            if(!($file.Name -like ".*")){
                $name=$file.Name
                $lastWriteTime=$file.LastWriteTime
                write-host "$name `t $lastWriteTime "
            }
        }
   } finally {
      # Disconnect, clean up
        $session.Dispose()
   }
   
   
} catch {
   write-host -foregroundcolor red "Download failed: $_"
}


WinSCPAssembly - PreserveTime=0, ConsiderDST=0
Code:
PS F:\Import> F:\Import\download-test.ps1
Name        LastWriteTime
test.test     04/20/2012 13:53:44


WinSCPAssembly - PreserveTime=1, ConsiderDST=0
Code:
PS F:\Import> F:\Import\download-test.ps1
Name        LastWriteTime
test.test     04/20/2012 13:53:44


WinSCPAssembly - PreserveTime=1, ConsiderDST=1
Code:
PS F:\Import> F:\Import\download-test.ps1
Name        LastWriteTime
test.test     04/20/2012 14:53:44


xml.log
Code:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="ftpuser" start="2012-04-20T13:31:39.844Z">
  <ls>
    <destination value="/home/ftpuser" />
    <files>
      <file>
        <filename value=".bashrc" />
        <type value="-" />
        <size value="124" />
        <modification value="2011-12-02T13:27:20.000Z" />
        <permissions value="rw-r--r--" />
      </file>
      <file>
        <filename value=".." />
        <type value="d" />
        <modification value="2012-04-18T10:27:50.000Z" />
        <permissions value="rwxr-xr-x" />
      </file>
      <file>
        <filename value=".viminfo" />
        <type value="-" />
        <size value="1056" />
        <modification value="2012-04-16T10:21:13.000Z" />
        <permissions value="rw-------" />
      </file>
      <file>
        <filename value="." />
        <type value="d" />
        <modification value="2012-04-20T12:53:44.000Z" />
        <permissions value="rwx------" />
      </file>
      <file>
        <filename value="test.test" />
        <type value="-" />
        <size value="0" />
        <modification value="2012-04-20T12:53:44.000Z" />
        <permissions value="rw-r--r--" />
      </file>
      <file>
        <filename value=".bash_profile" />
        <type value="-" />
        <size value="176" />
        <modification value="2011-12-02T13:27:20.000Z" />
        <permissions value="rw-r--r--" />
      </file>
      <file>
        <filename value=".bash_history" />
        <type value="-" />
        <size value="1429" />
        <modification value="2012-04-20T12:47:22.000Z" />
        <permissions value="rw-------" />
      </file>
      <file>
        <filename value=".bash_logout" />
        <type value="-" />
        <size value="18" />
        <modification value="2011-12-02T13:27:20.000Z" />
        <permissions value="rw-r--r--" />
      </file>
    </files>
    <result success="true" />
  </ls>
</session>
Client -time.png (53.77 KB)

Description: Client time+timezone

Client -time.png

WINSCPUI - Settings1.png (48.57 KB)

Description: Settings try 1

WINSCPUI - Settings1.png

WINSCPUI - Result1.png (18.89 KB)

Description: Results try 1

WINSCPUI - Result1.png

osram
[View user's profile]

Joined: 2012-04-18
Posts: 3
More attachments.
Thank you for you help!
WINSCPUI - Settings2.png (51.01 KB)

Description: Settings try 2

WINSCPUI - Settings2.png

WINSCPUI - Result2.png (18.58 KB)

Description: Results try 2

WINSCPUI - Result2.png

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Thanks for your report.

This bug has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=843
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Thanks for your report.
I have sent you an email with a development version of WinSCP to address you have used to register on this forum.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License