Regional settings and dates issue (found in ftime)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
onionfx
Posts: 1
Joined: 03 Mar 2009 11:39

Regional settings and dates issue (found in ftime)

#1 Post by onionfx » 03 Mar 2009 11:54

Hi,
Firstly excellent spot for batch info!

I'm using ftime and jdate in a wee script and it was producing unexpected results:
ftime was always returning todays date

With echo on I was able to step through and see the date passed to jdate from ftime was empty string.

I think I've tracked it down to this line of code

Code: Select all

'"dir %attr% /-c "%file%"|findstr "^^[0-1]""'

(line 31 here http://www.dostips.com/?t=Batch_FileDate)

I think this is looking for the string that starts with 0 or 1, which I'm guessing would be the only digits possible if you have the date in a US style format (month/day/year).
Here in the UK we like it day/month/year

Anyhow I changed this to [0-3] which covers the 'day' range and the code works as expected.


Whether or not the code should be changed on the site I don't know, but maybe a note or something - or even this post will help others with diff regional settings

Thanks again
onion

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 22 Mar 2009 22:44

onionfx,

You should name yourself hero not onion. The corrected :ftime function has been uploaded.
I also fixed the function comment, which was bogus, and made changes to improve the performance when default 'last file write' time is used, by preventing calls to 'dir' and 'findstr' altogether.

Many thanks for investigating and pointing this out!

DosItHelp

Post Reply