#=6/2006=====================================Version 0=#
#=========== "human readable" grid calendar ==========#
#
# To test :
#
# .\gadget-calendar
# °shows month calendar with current day
# highlighted (red on white by default)
# .\gadget-calendar "6/2006"|tee -file calendar.txt
# .\gadget-calendar "june 2006"|tee -file calendar.txt
# .\gadget-calendar "juin 2006"|tee -file calendar.txt
# °outputs june 2006 month grid and writes it
# to calendar.txt file
# .\gadget-calendar -fullyear 2006|tee -file calendar.txt
# °outputs full year 2006 grid (3 x 4) and writes it
# to calendar.txt file
#
# NOTE : gadget-calendar without parameters doesn't
# highlight current day if you call it directly
# after you've launched PowerShell (probably a
# console bug).
# If you recall gagdet-calendar, that works.
#
#======================================================#
function build_date_table($date){
#### Returns an array containing days numbers ####
#### and month name ####
## Sets variables containing month and year of the date ##
$m=$date.Month
$y=$date.Year
## Get month's first day position in the week ##
[datetime]$firstday=[string]$m+'/'+[string]$y
$fd=[int]$firstday.DayOfWeek
## As "dayofweek" is 0 indexed from Sunday to ##
## Saturday and we want from Monday to Sunday we ##
## use a "1 indexed" concept : ##
if($fd -eq 0){$fd=7}
## Sets a variable containing the number ##
## of days in the month ##
$ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m)
## Build an array containing days numbers relative ##
## to days names positions. ##
## If a position is not used, the value is set to ##
## a space char. ##
$table=@()
$rui=$host.UI.RawUI
## Stores current background/foreground console's colors ##
$oldfg=$rui.ForegroundColor
$oldbg=$rui.BackgroundColor
## Set console's colors for Month/Year line and grid ##
$rui.BackgroundColor=$calendarbg
if(!$fullyear){
$monthtable=build_date_table(get-date $strdate)
$monthyear=$monthtable[1]
$daystable=$monthtable[0]
$rui.ForegroundColor=$monthyearfg
## Ouputs month/year line ##
[string]$monthyear
## Set days names line foreground color ##
$rui.ForegroundColor=$daynamefg
## Outputs day names ##
' '+[string]$daysnames+' '
## Set days numbers foreground color ##
$rui.ForegroundColor=$dayfg
Voici une version 0.1 dans laquelle le bug de la mise en évidence du jour courant a été fixé grâce à MOW sur le groupe microsoft.public.windows.powershell dans le message d'id :
#=6/2006=====================================Version 0.1=# #=========== "human readable" grid calendar ==========# # # To test : # # .gadget-calendar # °shows month calendar with current day # highlighted (red on white by default) # .gadget-calendar "6/2006"|tee -file calendar.txt # .gadget-calendar "june 2006"|tee -file calendar.txt # .gadget-calendar "juin 2006"|tee -file calendar.txt # °outputs june 2006 month grid and writes it # to calendar.txt file # .gadget-calendar -fullyear 2006|tee -file calendar.txt # °outputs full year 2006 grid (3 x 4) and writes it # to calendar.txt file # # Thanks to MOW to have fix a previous annoying bug "current # day not always highlighted". # see this message on microsoft.public.windows.powershell : # #======================================================#
function build_date_table($date){ #### Returns an array containing days numbers #### #### and month name ####
## Sets variables containing month and year of the date ## $m=$date.Month $y=$date.Year ## Get month's first day position in the week ## [datetime]$firstday=[string]$m+'/'+[string]$y $fd=[int]$firstday.DayOfWeek ## As "dayofweek" is 0 indexed from Sunday to ## ## Saturday and we want from Monday to Sunday we ## ## use a "1 indexed" concept : ## if($fd -eq 0){$fd=7} ## Sets a variable containing the number ## ## of days in the month ## $ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m) ## Build an array containing days numbers relative ## ## to days names positions. ## ## If a position is not used, the value is set to ## ## a space char. ## $table=@()
$rui=(get-host).UI.RawUI ## Stores current background/foreground console's colors ## $oldfg=$rui.ForegroundColor $oldbg=$rui.BackgroundColor ## Set console's colors for Month/Year line and grid ## $rui.BackgroundColor=$calendarbg
if(!$fullyear){ $monthtable=build_date_table(get-date $strdate) $monthyear=$monthtable[1] $daystable=$monthtable[0] $rui.ForegroundColor=$monthyearfg ## Ouputs month/year line ## [string]$monthyear ## Set days names line foreground color ## $rui.ForegroundColor=$daynamefg ## Outputs day names ## ' '+[string]$daysnames+' ' ## Set days numbers foreground color ## $rui.ForegroundColor=$dayfg
Voici une version 0.1 dans laquelle le bug de la mise en évidence du
jour courant a été fixé grâce à MOW sur le groupe
microsoft.public.windows.powershell dans le message d'id :
Ozb94fPnGHA.4240@TK2MSFTNGP02.phx.gbl
#=6/2006=====================================Version 0.1=#
#=========== "human readable" grid calendar ==========#
#
# To test :
#
# .gadget-calendar
# °shows month calendar with current day
# highlighted (red on white by default)
# .gadget-calendar "6/2006"|tee -file calendar.txt
# .gadget-calendar "june 2006"|tee -file calendar.txt
# .gadget-calendar "juin 2006"|tee -file calendar.txt
# °outputs june 2006 month grid and writes it
# to calendar.txt file
# .gadget-calendar -fullyear 2006|tee -file calendar.txt
# °outputs full year 2006 grid (3 x 4) and writes it
# to calendar.txt file
#
# Thanks to MOW to have fix a previous annoying bug "current
# day not always highlighted".
# see this message on microsoft.public.windows.powershell :
# Ozb94fPnGHA.4240@TK2MSFTNGP02.phx.gbl
#======================================================#
function build_date_table($date){
#### Returns an array containing days numbers ####
#### and month name ####
## Sets variables containing month and year of the date ##
$m=$date.Month
$y=$date.Year
## Get month's first day position in the week ##
[datetime]$firstday=[string]$m+'/'+[string]$y
$fd=[int]$firstday.DayOfWeek
## As "dayofweek" is 0 indexed from Sunday to ##
## Saturday and we want from Monday to Sunday we ##
## use a "1 indexed" concept : ##
if($fd -eq 0){$fd=7}
## Sets a variable containing the number ##
## of days in the month ##
$ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m)
## Build an array containing days numbers relative ##
## to days names positions. ##
## If a position is not used, the value is set to ##
## a space char. ##
$table=@()
$rui=(get-host).UI.RawUI
## Stores current background/foreground console's colors ##
$oldfg=$rui.ForegroundColor
$oldbg=$rui.BackgroundColor
## Set console's colors for Month/Year line and grid ##
$rui.BackgroundColor=$calendarbg
if(!$fullyear){
$monthtable=build_date_table(get-date $strdate)
$monthyear=$monthtable[1]
$daystable=$monthtable[0]
$rui.ForegroundColor=$monthyearfg
## Ouputs month/year line ##
[string]$monthyear
## Set days names line foreground color ##
$rui.ForegroundColor=$daynamefg
## Outputs day names ##
' '+[string]$daysnames+' '
## Set days numbers foreground color ##
$rui.ForegroundColor=$dayfg
Voici une version 0.1 dans laquelle le bug de la mise en évidence du jour courant a été fixé grâce à MOW sur le groupe microsoft.public.windows.powershell dans le message d'id :
#=6/2006=====================================Version 0.1=# #=========== "human readable" grid calendar ==========# # # To test : # # .gadget-calendar # °shows month calendar with current day # highlighted (red on white by default) # .gadget-calendar "6/2006"|tee -file calendar.txt # .gadget-calendar "june 2006"|tee -file calendar.txt # .gadget-calendar "juin 2006"|tee -file calendar.txt # °outputs june 2006 month grid and writes it # to calendar.txt file # .gadget-calendar -fullyear 2006|tee -file calendar.txt # °outputs full year 2006 grid (3 x 4) and writes it # to calendar.txt file # # Thanks to MOW to have fix a previous annoying bug "current # day not always highlighted". # see this message on microsoft.public.windows.powershell : # #======================================================#
function build_date_table($date){ #### Returns an array containing days numbers #### #### and month name ####
## Sets variables containing month and year of the date ## $m=$date.Month $y=$date.Year ## Get month's first day position in the week ## [datetime]$firstday=[string]$m+'/'+[string]$y $fd=[int]$firstday.DayOfWeek ## As "dayofweek" is 0 indexed from Sunday to ## ## Saturday and we want from Monday to Sunday we ## ## use a "1 indexed" concept : ## if($fd -eq 0){$fd=7} ## Sets a variable containing the number ## ## of days in the month ## $ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m) ## Build an array containing days numbers relative ## ## to days names positions. ## ## If a position is not used, the value is set to ## ## a space char. ## $table=@()
$rui=(get-host).UI.RawUI ## Stores current background/foreground console's colors ## $oldfg=$rui.ForegroundColor $oldbg=$rui.BackgroundColor ## Set console's colors for Month/Year line and grid ## $rui.BackgroundColor=$calendarbg
if(!$fullyear){ $monthtable=build_date_table(get-date $strdate) $monthyear=$monthtable[1] $daystable=$monthtable[0] $rui.ForegroundColor=$monthyearfg ## Ouputs month/year line ## [string]$monthyear ## Set days names line foreground color ## $rui.ForegroundColor=$daynamefg ## Outputs day names ## ' '+[string]$daysnames+' ' ## Set days numbers foreground color ## $rui.ForegroundColor=$dayfg
#=9/2006=====================================Version 1=# #=========== "human readable" grid calendar ============# # # To test : # # .gadget-calendar # °shows month calendar with current day # highlighted (red on white by default) # .gadget-calendar "6/2006"|tee -file calendar.txt # .gadget-calendar "june 2006"|tee -file calendar.txt # .gadget-calendar "juin 2006"|tee -file calendar.txt # °outputs june 2006 month grid and writes it # to calendar.txt file # .gadget-calendar 2006|tee -file calendar.txt # °outputs full year 2006 grid (3 x 4) and writes it # to calendar.txt file # # Thanks to MOW to have fix a previous ennoying bug "current # day not always highlighted". # See this message on microsoft.public.windows.powershell : # #========================================================#
function build_date_table($date){ #### Returns an array containing days numbers #### #### and month name ####
## Sets variables containing month and year of the date ## $m=$date.Month $y=$date.Year ## Get month's first day position in the week ## [datetime]$firstday=[string]$m+'/'+[string]$y $fd=[int]$firstday.DayOfWeek ## As "dayofweek" is 0 indexed from Sunday to ## ## Saturday and we want from Monday to Sunday we ## ## use a "1 indexed" concept : ## if($fd -eq 0){$fd=7} ## Sets a variable containing the number ## ## of days in the month ## $ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m) ## Build an array containing days numbers relative ## ## to days names positions. ## ## If a position is not used, the value is set to ## ## a space char. ## $table=@()
$rui=(get-host).UI.RawUI ## Stores current background/foreground console's colors ## $oldfg=$rui.ForegroundColor $oldbg=$rui.BackgroundColor ## Set console's colors for Month/Year line and grid ## $rui.BackgroundColor=$calendarbg
## If an integer is passed for $vardate then defines ## ## $fullyear to $vardate ## if($vardate.GetTypeCode() -eq "Int32"){$fullyear=$vardate}
if(!$fullyear){ $monthtable=build_date_table(get-date $vardate) $monthyear=$monthtable[1] $daystable=$monthtable[0] $rui.ForegroundColor=$monthyearfg ## Ouputs month/year line ## [string]$monthyear ## Set days names line foreground color ## $rui.ForegroundColor=$daynamefg ## Outputs day names ## ' '+[string]$daysnames+' ' ## Set days numbers foreground color ## $rui.ForegroundColor=$dayfg
#=9/2006=====================================Version 1=#
#=========== "human readable" grid calendar ============#
#
# To test :
#
# .gadget-calendar
# °shows month calendar with current day
# highlighted (red on white by default)
# .gadget-calendar "6/2006"|tee -file calendar.txt
# .gadget-calendar "june 2006"|tee -file calendar.txt
# .gadget-calendar "juin 2006"|tee -file calendar.txt
# °outputs june 2006 month grid and writes it
# to calendar.txt file
# .gadget-calendar 2006|tee -file calendar.txt
# °outputs full year 2006 grid (3 x 4) and writes it
# to calendar.txt file
#
# Thanks to MOW to have fix a previous ennoying bug "current
# day not always highlighted".
# See this message on microsoft.public.windows.powershell :
# Ozb94fPnGHA.4240@TK2MSFTNGP02.phx.gbl
#========================================================#
function build_date_table($date){
#### Returns an array containing days numbers ####
#### and month name ####
## Sets variables containing month and year of the date ##
$m=$date.Month
$y=$date.Year
## Get month's first day position in the week ##
[datetime]$firstday=[string]$m+'/'+[string]$y
$fd=[int]$firstday.DayOfWeek
## As "dayofweek" is 0 indexed from Sunday to ##
## Saturday and we want from Monday to Sunday we ##
## use a "1 indexed" concept : ##
if($fd -eq 0){$fd=7}
## Sets a variable containing the number ##
## of days in the month ##
$ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m)
## Build an array containing days numbers relative ##
## to days names positions. ##
## If a position is not used, the value is set to ##
## a space char. ##
$table=@()
$rui=(get-host).UI.RawUI
## Stores current background/foreground console's colors ##
$oldfg=$rui.ForegroundColor
$oldbg=$rui.BackgroundColor
## Set console's colors for Month/Year line and grid ##
$rui.BackgroundColor=$calendarbg
## If an integer is passed for $vardate then defines ##
## $fullyear to $vardate ##
if($vardate.GetTypeCode() -eq "Int32"){$fullyear=$vardate}
if(!$fullyear){
$monthtable=build_date_table(get-date $vardate)
$monthyear=$monthtable[1]
$daystable=$monthtable[0]
$rui.ForegroundColor=$monthyearfg
## Ouputs month/year line ##
[string]$monthyear
## Set days names line foreground color ##
$rui.ForegroundColor=$daynamefg
## Outputs day names ##
' '+[string]$daysnames+' '
## Set days numbers foreground color ##
$rui.ForegroundColor=$dayfg
#=9/2006=====================================Version 1=# #=========== "human readable" grid calendar ============# # # To test : # # .gadget-calendar # °shows month calendar with current day # highlighted (red on white by default) # .gadget-calendar "6/2006"|tee -file calendar.txt # .gadget-calendar "june 2006"|tee -file calendar.txt # .gadget-calendar "juin 2006"|tee -file calendar.txt # °outputs june 2006 month grid and writes it # to calendar.txt file # .gadget-calendar 2006|tee -file calendar.txt # °outputs full year 2006 grid (3 x 4) and writes it # to calendar.txt file # # Thanks to MOW to have fix a previous ennoying bug "current # day not always highlighted". # See this message on microsoft.public.windows.powershell : # #========================================================#
function build_date_table($date){ #### Returns an array containing days numbers #### #### and month name ####
## Sets variables containing month and year of the date ## $m=$date.Month $y=$date.Year ## Get month's first day position in the week ## [datetime]$firstday=[string]$m+'/'+[string]$y $fd=[int]$firstday.DayOfWeek ## As "dayofweek" is 0 indexed from Sunday to ## ## Saturday and we want from Monday to Sunday we ## ## use a "1 indexed" concept : ## if($fd -eq 0){$fd=7} ## Sets a variable containing the number ## ## of days in the month ## $ld=(Get-Culture).Calendar.GetDaysInMonth($y,$m) ## Build an array containing days numbers relative ## ## to days names positions. ## ## If a position is not used, the value is set to ## ## a space char. ## $table=@()
$rui=(get-host).UI.RawUI ## Stores current background/foreground console's colors ## $oldfg=$rui.ForegroundColor $oldbg=$rui.BackgroundColor ## Set console's colors for Month/Year line and grid ## $rui.BackgroundColor=$calendarbg
## If an integer is passed for $vardate then defines ## ## $fullyear to $vardate ## if($vardate.GetTypeCode() -eq "Int32"){$fullyear=$vardate}
if(!$fullyear){ $monthtable=build_date_table(get-date $vardate) $monthyear=$monthtable[1] $daystable=$monthtable[0] $rui.ForegroundColor=$monthyearfg ## Ouputs month/year line ## [string]$monthyear ## Set days names line foreground color ## $rui.ForegroundColor=$daynamefg ## Outputs day names ## ' '+[string]$daysnames+' ' ## Set days numbers foreground color ## $rui.ForegroundColor=$dayfg
Ormis la résolution d'un petit bug d'affichage j'ai retiré le paramètre -fullyear. En lieu et place il suffit de passer un entier (représentant l'année) en premier paramètre.
Par souci de cohésion le (premier) paramètre -strdate a été renommé -vardate.
On peut donc taper :
.gadget-calendar.ps1 2008
pour afficher le calendrier complet de l'année 2008
.gadget-calendar.ps1 "1/2008" ou .gadget-calendar.ps1 "january 2008" ou .gadget-calendar.ps1 "janvier 2008"
Ormis la résolution d'un petit bug d'affichage j'ai retiré
le paramètre -fullyear.
En lieu et place il suffit de passer un entier (représentant l'année)
en premier paramètre.
Par souci de cohésion le (premier) paramètre -strdate a été renommé
-vardate.
On peut donc taper :
.gadget-calendar.ps1 2008
pour afficher le calendrier complet de l'année 2008
.gadget-calendar.ps1 "1/2008"
ou
.gadget-calendar.ps1 "january 2008"
ou
.gadget-calendar.ps1 "janvier 2008"
Ormis la résolution d'un petit bug d'affichage j'ai retiré le paramètre -fullyear. En lieu et place il suffit de passer un entier (représentant l'année) en premier paramètre.
Par souci de cohésion le (premier) paramètre -strdate a été renommé -vardate.
On peut donc taper :
.gadget-calendar.ps1 2008
pour afficher le calendrier complet de l'année 2008
.gadget-calendar.ps1 "1/2008" ou .gadget-calendar.ps1 "january 2008" ou .gadget-calendar.ps1 "janvier 2008"
pour afficher le mois de janvier 2008
Amicalement,
-- Jean - JMST Belgium
Jean
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de débugger ce soir, j'ai juste constaté que le problème apparaît avec la ligne suivante
Merci du retour. C'est assez gênant en effet. Je ne reproduis pas le problème ici avec la RC1. Je pense que c'est une question de version (vous utilisez déjà la RC 2 je crois). Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une différence de traitement dans la RC2.
Amicalement,
-- Jean - JMST Belgium
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge
s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de débugger
ce soir, j'ai juste constaté que le problème apparaît avec la ligne suivante
Merci du retour.
C'est assez gênant en effet.
Je ne reproduis pas le problème ici avec la RC1.
Je pense que c'est une question de version (vous utilisez déjà la RC 2
je crois).
Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une
différence de traitement dans la RC2.
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de débugger ce soir, j'ai juste constaté que le problème apparaît avec la ligne suivante
Merci du retour. C'est assez gênant en effet. Je ne reproduis pas le problème ici avec la RC1. Je pense que c'est une question de version (vous utilisez déjà la RC 2 je crois). Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une différence de traitement dans la RC2.
Amicalement,
-- Jean - JMST Belgium
Jacques Barathon [MS]
"Jean" a écrit dans le message de news:
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de débugger ce soir, j'ai juste constaté que le problème apparaît avec la ligne suivante
Merci du retour. C'est assez gênant en effet. Je ne reproduis pas le problème ici avec la RC1. Je pense que c'est une question de version (vous utilisez déjà la RC 2 je crois). Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une différence de traitement dans la RC2.
J'utilise une version post-RC1, mais ce n'est pas la RC2. J'essaierai de creuser le sujet dans la journée.
Jacques
"Jean" <repondre@groupe.svp> a écrit dans le message de news:
mn.40417d69d9c730c4.56820@windows...
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge
s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de
débugger ce soir, j'ai juste constaté que le problème apparaît avec la
ligne suivante
Merci du retour.
C'est assez gênant en effet.
Je ne reproduis pas le problème ici avec la RC1.
Je pense que c'est une question de version (vous utilisez déjà la RC 2 je
crois).
Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une différence
de traitement dans la RC2.
J'utilise une version post-RC1, mais ce n'est pas la RC2. J'essaierai de
creuser le sujet dans la journée.
J'ai un problème d'affichage quand j'essaie le script. Une ligne vierge s'intercale entre deux lignes du calendrier. Je n'ai pas le temps de débugger ce soir, j'ai juste constaté que le problème apparaît avec la ligne suivante
Merci du retour. C'est assez gênant en effet. Je ne reproduis pas le problème ici avec la RC1. Je pense que c'est une question de version (vous utilisez déjà la RC 2 je crois). Dans l'affirmative, reste à voir si il sagit d'un bug ou d'une différence de traitement dans la RC2.
J'utilise une version post-RC1, mais ce n'est pas la RC2. J'essaierai de creuser le sujet dans la journée.
Jacques
Jean
J'utilise une version post-RC1, mais ce n'est pas la RC2. J'essaierai de creuser le sujet dans la journée.
C'est sympa :-)
Juste une idée avant d'incriminer la version.
Voir si ça ne se résoudrait pas en mettant au tout début du script :
$oldOFS=$OFS $OFS=" "
et à la toute fin du script
$OFS=$oldOFS
Amicalement,
-- Jean - JMST Belgium
J'utilise une version post-RC1, mais ce n'est pas la RC2. J'essaierai de
creuser le sujet dans la journée.
C'est sympa :-)
Juste une idée avant d'incriminer la version.
Voir si ça ne se résoudrait pas en mettant au tout début du script :