[Solved]jdate doesn't work with custom regional settings????

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

[Solved]jdate doesn't work with custom regional settings????

#1 Post by avery_larry » 27 Mar 2009 15:16

I'm not going to pretend to completely understand julian . . .

The code doesn't seem to differentiate between 4 digit year and 2 digit year format. On my machine with a 4 digit year, :jdate %date% returns 2454918 where %date% is "Fri 03/27/2009". On my custom computer with a 2 digit year, :jdate %date% returns 1724433 where %date% is "03/27/09".

Perhaps this is accounted for by the specs -- which state a 4 digit year -- but then it proceeds to use the system variable %date% if nothing else is given (plus it claims to match regional settings--which it does other than the 2 digit/4 digit date (I think)).

I guess it would be too complicated perhaps to try and code an intelligent guess. Something like "if I must use %date%, then set yy=2000 + yy %% 2000 before calculating the julian date"?

Or if (and ONLY if) %date% is used, then assume the current date is at least 2000 -- then it would be:

Code: Select all

set /a "yy=10000%yy% %% 10000 %% 2000 + 2000,mm=100%mm% %% 100,dd=100%dd% %% 100"


Maybe I'm thinking too much. ?

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

#2 Post by DosItHelp » 28 Mar 2009 23:23

avery_larry,

Good thinking!
The functions :jdate and :date2jdate have been corrected to support 2 digit years by adding 2000.
Give it a try and let me know of the :jdate function now works for you.
http://www.dostips.com/DtCodeCmdLib.php#jdate

Thanks,
DosItHelp

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#3 Post by avery_larry » 30 Mar 2009 08:15

Indeed -- that works just great.

Post Reply