2008 Scripting Games - Advanced Event 4
Event 4: Image is Everything
function print-calendar($dte){ $month,$year = $dte.split("/") $dtfi = new-object system.globalization.datetimeformatinfo $AbbreviatedDayNames=$dtfi.AbbreviatedDayNames | foreach {" {0}" -f $_} $header= "$($dtfi.MonthNames[$month-1]) $year" write-host $header write-host ([string]::join("",$AbbreviatedDayNames)) $daysInMonth=[datetime]::DaysInMonth($year,$month) $dayOfWeek =(new-object datetime $year,$month,1).dayOfWeek.value__ $today=(get-date).day for ($i = 0; $i -lt $dayOfWeek; $i++){write-host (" "*4) -nonew} for ($i = 1; $i -le $daysInMonth; $i++) { if($today -eq $i){write-host ("{0,4}" -f $i) -nonew} else {write-host ("{0,4}" -f $i) -nonew} if ($dayOfWeek -eq 6) {write-host} $dayOfWeek = ($dayOfWeek + 1) % 7 } if ($dayOfWeek -ne 0) {write-host} } print-calendar 2/2008
February 2008 Sun Mon Tue Wed Thu Fri Sat 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
No comments:
Post a Comment