@Echo Off :: GREGOR.BTM Convert Julian Day Number to Gregorian Date :: Author: Michael Bednarek (mb@doh.health.nsw.gov.au) :: Input: nnnnnnn :: Output: Echo DOW and GREGOR and return variable GREGOR :: Method: From a German HP Calculator Manual :: which says it only works for dates between 1-Mar-1900 and 28-Feb-2100 :: Seems to work longer, though. :: Parameter is not checked! :: bias to 1-Jan-4713 BC Set bias=1720983 :: Compute preliminary year and month, and day Set y2=%@Int[%@Eval[(%1 - %bias - 122.1) / 365.25]] Set m2=%@Int[%@Eval[(%1 - %bias - %@Int[%@Eval[365.25 * %y2]])/30.6001]] Set dd=%@Eval[%1 - %bias - %@Int[%@Eval[365.25 * %y2]] - %@Int[%@Eval[30.6001 * %m2]]] :: Correct month and year Iff %m2 gt 13 Then Set mm=%@Eval[%m2 - 13] Set yy=%@Eval[%y2 + 1] Else Set mm=%@Eval[%m2 - 1] Set yy=%y2 EndIff :: Done Set GREGOR=%dd %mm %yy Set DOW=%@Word[%@Eval[%1 %% 7],Sun,Mon,Tue,Wed,Thu,Fri,Sat] :: Clean up Unset y2 m2 dd mm yy bias :: Echo only if called from the command line If %_BATCH eq 1 Echo %GREGOR %DOW