1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
@echo off
:: Xp batch for generating calendars
:: Chances look good for win 2000 and above(untested)
:: By Judago, August 2009
IF "%~1"=="/?" (
ECHO START "%~NX0" WITHOUT ARGUMENTS AND THEN ENTER THE YEAR.
ECHO "%~NX0" WILL OPEN IN IT'S OWN WINDOW TO AVOID RESIZING
ECHO AN EXISTING WINDOW.
ECHO.
ECHO A SCREEN RESOLUTION AND/OR FONT SIZE THAT CAN DISPLAY
ECHO CMD WINDOWS OF 96 COLUMNS AND 39 LINES IS REQUIRED.
ECHO SOME CONFIGURATIONS MAY USE SCROLL BARS TO ACHIEVE
ECHO THIS.
EXIT /B
)
:: The current codepage is stored in variable %CodePage%,
:: then changed to 850 to facilitate box drawing characters.....
FOR /F "tokens=*" %%A IN ('CHCP') DO FOR %%B IN (%%~A) DO SET CodePage=%%B
CHCP 850 >NUL 2>&1
:: The title can be used to falicitate custom window
:: positioning via the properties menu of "calendars..."
:: /max is used so as much content as possible is visable
:: without moving the window. /max must be removed for
:: custom window positing.....
IF NOT "%~1 %~2"=="WINDOW SIZE" (
START "CALENDRIERS..." /MAX CMD /C "%~F0" WINDOW SIZE
REM Restore the original codepage before exiting.....
CHCP %CodePage% >NUL 2>&1
EXIT /B
)
MODE CON:COLS=96 LINES=39
SETLOCAL ENABLEDELAYEDEXPANSION
:loop
FOR %%Z IN (jan feb mar apr may jun jul aug sep oct nov dec year day leap noleap length test) DO SET %%Z=
SET /P year=Entrez l'anne pour afficher le calendrier, ou rien pour quitter, puis pressez entre:
IF NOT DEFINED year (
REM Restore the original codepage before exiting.....
CHCP %CodePage% >NUL 2>&1
EXIT /B
)
::Test that the input is only numbers...
SET test=!year!
FOR /l %%Z IN (0 1 9) DO IF DEFINED test SET "test=!test:%%Z=!"
IF DEFINED test CLS&GOTO loop
:zero
IF NOT DEFINED year (
:error
cls
echo L'anne entre n'est pas accepte.
echo.
pause
CLS
GOTO loop
)
:: remove leading zeros, if any...
IF "%year:~0,1%"=="0" SET year=%year:~1%&&GOTO zero
:: The %processor_architecture% test is used to test
:: limits of caculations, if the variable is undefined
:: or unrecognised the test will fall through and complete
:: anyway, if the limit is surpassed this way the results may
:: not be valid. The tested number is ~80% of the limit of the
:: os so that year + year / 4 yields a valid result.
IF /I "!processor_architecture!"=="x86" (
IF !year! gtr 1717986917 GOTO :error
) else (
IF NOT "!processor_architecture:64=!"=="!processor_architecture!" (
IF !year! gtr 7378697629483820645 GOTO :error
)
)
:: Generate the first day of the year, 0=sun, 1=mon,...,6=sat
:: A 365 day year ofsets by one day, so the next year will start
:: the next day (i.e. 2009 starts on thr and 2010 starts on fri)
:: an extra day must be added for every leapyear. Using modulo
:: 7 on the total of offset days reviels the starting day of the
:: year. one day must also be removed if the year is a leap year
:: because the below will add one for it, the remainder for non
:: leap years is not an issue because set /a only returns whole
:: numbers.
SET /A day=(year + year / 4) - (year / 100 - year / 400)
SET /A leap=year %% 400
SET /A noleap=year %% 100
IF !leap! GTR 0 (
IF !noleap! NEQ 0 SET /A leap=year %% 4
)
IF %leap%==0 SET /A day-=1
SET /A day%%=7
:: For each year every month is padded to is starting offset
:: with spaces, january has the original offset generated above.
:: each additional offset is generated by adding the total days of
:: the previous month then processing it by modulo 7.
:: The days are stored in a varianle to display later, these variables
:: are padded to 111 characters using spaces for display purposes.
FOR %%U IN (jan feb mar apr may jun jul aug sep oct nov dec) DO (
FOR %%V IN (jan mar may jul aug oct dec) DO IF /I %%U==%%V SET length=31
FOR %%W IN (apr jun sep nov) DO IF /I %%U==%%W SET length=30
IF /I %%U==feb (
IF !leap!==0 (
SET length=29
) else (
SET length=28
)
)
FOR /l %%X IN (1 1 !day!) DO SET "%%U=!%%U! "
FOR /l %%Y IN (1 1 !length!) DO (
IF %%Y lss 10 (
SET "%%U=!%%U!%%Y "
) else (
SET "%%U=!%%U!%%Y "
)
)
FOR /l %%Z IN (!length! 1 54) DO IF "!%%U:~110!"=="" SET "%%U=!%%U! "
SET /A day=^(day + length^) %% 7
)
:test
:: The results are displayed below using substrings of each month's
variable.
cls
TITLE CALENDRIER DE L'ANNE %YEAR%
echo. ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป
echo. บ JANVIER บ บ FEVRIER บ บ MARS บ บ AVRIL บ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บ%JAN:~0,20%บ บ%FEB:~0,20%บ บ%MAR:~0,20%บ บ%APR:~0,20%บ
echo. บ%JAN:~21,20%บ บ%FEB:~21,20%บ บ%MAR:~21,20%บ บ%APR:~21,20%บ
echo. บ%JAN:~42,20%บ บ%FEB:~42,20%บ บ%MAR:~42,20%บ บ%APR:~42,20%บ
echo. บ%JAN:~63,20%บ บ%FEB:~63,20%บ บ%MAR:~63,20%บ บ%APR:~63,20%บ
echo. บ%JAN:~84,20%บ บ%FEB:~84,20%บ บ%MAR:~84,20%บ บ%APR:~84,20%บ
echo. บ%JAN:~105% บ บ%FEB:~105% บ บ%MAR:~105% บ บ%APR:~105% บ
echo. ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ
echo. ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป
echo. บ MAI บ บ JUIN บ บ JUILLET บ บ AOUT บ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บ%MAY:~0,20%บ บ%JUN:~0,20%บ บ%JUL:~0,20%บ บ%AUG:~0,20%บ
echo. บ%MAY:~21,20%บ บ%JUN:~21,20%บ บ%JUL:~21,20%บ บ%AUG:~21,20%บ
echo. บ%MAY:~42,20%บ บ%JUN:~42,20%บ บ%JUL:~42,20%บ บ%AUG:~42,20%บ
echo. บ%MAY:~63,20%บ บ%JUN:~63,20%บ บ%JUL:~63,20%บ บ%AUG:~63,20%บ
echo. บ%MAY:~84,20%บ บ%JUN:~84,20%บ บ%JUL:~84,20%บ บ%AUG:~84,20%บ
echo. บ%MAY:~105% บ บ%JUN:~105% บ บ%JUL:~105% บ บ%AUG:~105% บ
echo. ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ
echo. ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป ษออออออออออออออออออออป
echo. บ SEPTEMBRE บ บ OCTOBRE บ บ NOVEMBRE บ บ DECEMBRE บ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ บDi Lu Ma Me Je Ve Saบ
echo. ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน ฬออออออออออออออออออออน
echo. บ%SEP:~0,20%บ บ%OCT:~0,20%บ บ%NOV:~0,20%บ บ%DEC:~0,20%บ
echo. บ%SEP:~21,20%บ บ%OCT:~21,20%บ บ%NOV:~21,20%บ บ%DEC:~21,20%บ
echo. บ%SEP:~42,20%บ บ%OCT:~42,20%บ บ%NOV:~42,20%บ บ%DEC:~42,20%บ
echo. บ%SEP:~63,20%บ บ%OCT:~63,20%บ บ%NOV:~63,20%บ บ%DEC:~63,20%บ
echo. บ%SEP:~84,20%บ บ%OCT:~84,20%บ บ%NOV:~84,20%บ บ%DEC:~84,20%บ
echo. บ%SEP:~105% บ บ%OCT:~105% บ บ%NOV:~105% บ บ%DEC:~105% บ
echo. ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ ศออออออออออออออออออออผ
GOTO loop |
Partager