The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

goldfinger (9) [Avatar] Offline
I want to do a simple thing,- show the day of week in the german language.
The systems are running english OS with german MUI package. Default settings are english.
I can I do this? What is wrong on the code?

Here the code:

$OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture

$newCultureInfo = new-object Globalization.CultureInfo('de-DE')
[System.Threading.Thread]::CurrentThread.CurrentCulture = $newCultureInfo
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $newCultureInfo

# verify
$currentCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture

# Now make some tests
$d="07.10.2007" # German notation for Sunday, 10/08/2007

([datetime] $d).dayofweek

([datetime]:smiliearse($d, [Globalization.CultureInfo] 'de-DE')).dayofweek

'output form get-date:'

The output:

LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)

1031 de-DE German (Germany)

1031 de-DE Deutsch (Deutschland) -> Theadsettings are right

Tuesday -> Surprise I thought the output is in german language and has the right datetime format but it will use en-US
Sunday -> Right Day of Week (but wrong language)

output form get-date: -> Should the DayofWeek field be in german language like the DateTime one?
DisplayHint : DateTime
DateTime : Sonntag, 7. Oktober 2007 16:18:53
Date : 07.10.2007 00:00:00
Day : 7
DayOfWeek : Sunday
DayOfYear : 280
Hour : 16
Kind : Local
Millisecond : 252
Minute : 18
Month : 10
Second : 53
Ticks : 633273707332525488
TimeOfDay : 16:18:53.2525488
Year : 2007
goldfinger (9) [Avatar] Offline
Re: datetime and culture
After playing a little bit arround I found a solution but I still have now idea what's going wrong in the code before.


$de = new-object System.Globalization.CultureInfo "de-DE"
$wd = ([datetime]:smiliearse("07.10.2007", [Globalization.CultureInfo] 'de-DE')).dayofweek