View Single Post
Old 08-31-2007   #7 (permalink)
Kiron


 
 

Re: Need help with .CreationTime

Here's another way. Use Get-Date's Unix format parameter '-uFormat' and the
'week of year' value '%V'

get-date -uFormat %V

function Get-WeekOfYear ([dateTime]$date = (get-date))
{
get-date $date -uFormat %V
}

New-Alias woy Get-WeekOfYear -opt ReadOnly, AllScope -sco Global

.... you can add the scriptProperty to the [DateTime] type.

-- ExtendedTypes.ps1xml --
<Types>
<Type>
<Name>System.DateTime</Name>
<Members>
<ScriptProperty>
<Name>WeekOfYear</Name>
<GetScriptBlock>
get-date $this -uFormat %V
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
-- ExtendedTypes.ps1xml --

....and extend the type from your $profile.

Update-TypeData ExtendedTypes.ps1xml

# call the function
woy
35
woy '7.4.1776'
27

# read the property
(get-date).weekOfYear
35
([dateTime]'7.4.1776').weekOfYear
27

--
Kiron

My System SpecsSystem Spec