Calendar: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|F Sharp}}: Regularize header markup to recommended on category page) |
|||
Line 9,544: | Line 9,544: | ||
=={{header|VBScript}}== |
|||
VBScript has a good set of time-date functions. The program issues its output line to line to stdout so it can ba redirected to file or to printer. By deault the code will print the calender in your locale, you can chenge it. |
|||
<lang vb> |
|||
'call it with year, number of months per row (1,2,3,4,6) and locale ("" for default) |
|||
docal 2022,6,"" |
|||
function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function |
|||
sub print(x) wscript.stdout.writeline x : end sub |
|||
function iif(a,b,c) :if a then iif=b else iif =c end if : end function |
|||
sub docal (yr,nmonth,sloc) |
|||
dim ld(6) |
|||
dim d(6) |
|||
if nmonth=5 or nmonth>6 then wscript.stderr.writeline "Can't use width " & nmonth :exit sub |
|||
if sloc<>"" then Setlocale sloc |
|||
for i=1 to 7 |
|||
wday=wday &" "&left(weekdayname(i,true,vbUseSystemDayOfWeek),2) |
|||
next |
|||
ncols=nmonth*21+(nmonth-1)*1 |
|||
print center(yr,ncols) |
|||
print string(ncols,"=") |
|||
for i=1 to 12\nmonth |
|||
s="": s1="":esp="" |
|||
for j=1 to nmonth |
|||
s=s & esp & center(monthname(m+j),21) |
|||
s1=s1 & esp & wday |
|||
d(j)= -weekday(dateserial(yr,m+j,1),vbUseSystemDayOfWeek)+2 |
|||
ld(j)=day(dateserial(yr,m+j+1,0)) |
|||
esp=" " |
|||
next |
|||
print s: print s1 |
|||
while(d(1)<ld(1)) or (d(2)<ld(2)) or (d(3)<ld(3)) or (d(4)<ld(4)) |
|||
s="" |
|||
for j=1 to nmonth |
|||
for k=1 to 7 |
|||
s=s& right(space(3)&iif(d(j)<1 or d(j)>ld(j),"",d(j)),3) |
|||
d(j)=d(j)+1 |
|||
next |
|||
s=s&" " |
|||
next |
|||
print s |
|||
wend |
|||
m=m+nmonth |
|||
if i<>12\nmonth then print "" |
|||
next |
|||
print string(ncols,"=") |
|||
end sub |
|||
</lang> |
|||
output |
|||
<pre> |
|||
2022 |
|||
=================================================================================================================================== |
|||
enero febrero marzo abril mayo junio |
|||
lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do |
|||
1 2 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 1 1 2 3 4 5 |
|||
3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 |
|||
10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 |
|||
17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 |
|||
24 25 26 27 28 29 30 28 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 |
|||
julio agosto septiembre octubre noviembre diciembre |
|||
lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do lu ma mi ju vi sá do |
|||
1 2 3 1 2 3 4 5 6 7 1 2 3 4 1 2 1 2 3 4 5 6 1 2 3 4 |
|||
4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 |
|||
11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 |
|||
18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 |
|||
25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 |
|||
=================================================================================================================================== |
|||
</pre> |
|||
=={{header|WYLBUR}}== |
=={{header|WYLBUR}}== |