home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
4datef.exe
/
WEEK.BTM
< prev
Wrap
Text File
|
1992-10-05
|
1KB
|
57 lines
@echo off^goto Week_start
:WEEK_help
text
WEEK - The number of the week. Returns the week number for a given date
Command line usage: WEEK [/?] [<date>]
Batch file usage: WEEK [/?] [<date_variable>]
If WEEK is called from a batch file with a variable name, day of week
is returned in the variable, otherwise shown on screen, using echos.
<Date> defaults to the current system date. Format depends on country
settings. Only dates in between years 1980 and 2079 are valid.
Switches: /? - Display this help screen
endtext
return
:WEEK_start
if %_batch eq 1 setlocal
if "%debug" eq "%@name[%0]" echo on
iff "%@substr[%1,0,1]" eq "/" then
if "%1" eq "/?" (gosub WEEK_help^quit)
if %_batch eq 1 echo DOW: Invalid switch: %1
quit 2
endiff
iff "%1" eq "" then
set Dt=%_date
elseiff %_batch eq 1 then
set Dt=%1
else
set Dt=%[%1]
endiff
set Yr=%@substr[%Dt,6,2]
set Dt=%@date[%Dt]
set Wk=%@int[%@eval[(%Dt-(%Dt+1)%%7-%@date[01.01.%Yr])/7+1.5]]
iff %Wk eq 53 then
REM Check if it is not the 1st week of the next Year:
if %@eval[(%@date[31.12.%Yr]+1)%%7] lt 3 set Wk=1
elseiff %Wk eq 0 then
REM The Week belongs to the last Year:
set Wk=31.12.%@eval[%Yr-1]
call %0 Wk
endiff
iff %_batch gt 1 .and. "%1" ne "" then
set %1=%Wk
else
echos %Wk
endiff
unset Yr Dt Wk >& nul