Home » Questions » Computers [ Ask a new question ]

ls in cmd window gives one hour off time

ls in cmd window gives one hour off time

I have ls installed on my Windows XP computer. It came with msysgit. I've had it a while and it turns out I use it quite a lot even in the DOS prompt. More than dir.

Asked by: Guest | Views: 213
Total answers/comments: 1
Guest [Entry]

"It looks like the ls command doesn't know enough about European time-zomes and the dates when CEST is in effect.

I'm guessing the 16:01 reported by DIR was 16:01 CEST, but the ls command hasn't applied the extra hour for daylight saving.

I'm not sure how msysgit (or just msys) stores timezone information: in Solaris, there are zoneinfo files for this.

If there's some way of communicating to your msysgit tools when the daylight saving begins and ends, then your ls command could get it right.

Maybe this page offers a clue.
Try playing around with environment settings like

SET TZ=CET+1CEST,M3.5.0/2,M10.5.0/2

which states that CEST begins on the last Sunday (day 0) of March at 2am, and ends on the last Sunday of October at 2am. That should give you something to work with.

(Normally, it would be enough to state the timezone and DST timezone only: ""CET+1CEST"" and rely on the OS to know what the relevant dates should be. But here we are setting the dates explicitly.)

I can see the something similar happening in reverse with MSys on my system:
A file reported by the DIR command (and Windows Explorer) as written on 2008-04-18 at 12:19 (which should have been BST: GMT+1) is shown by MSys ls as 13:19:06.

If I play around with the timezone dates and SET TZ as though DST did not begin until the end of April, I can change this to match DIR's output.

But as far as I know, the EU-wide rule on Summer-time is that it begins on the last Sunday of March (M3.5.0/2) and ends on the last Sunday of October (M10.5.0/2).

So when I type (in an MSys shell, or in Cygwin, or in Unix):

TZ=GMT0BST,M3.5.0/2,M10.5.0/2 ls --full-time foo

I should see the correct time, with DST applied. In fact I see 13:19, just the same as when I don't set the timezone at all.

Which makes me wonder if MSys and msysgit are getting it right, and Windows is getting it wrong."