Closed jonathan-vogel-siemens closed 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/area-system-globalization See info in area-owners.md if you want to be subscribed.
Author: | Jonathan-a35y |
---|---|
Assignees: | - |
Labels: | `area-System.Globalization`, `untriaged` |
Milestone: | - |
@Jonathan-a35y de-DE
culture contains Genitive Month Names. if you call DateTimeFormat.AbbreviatedMonthGenitiveNames
you will see the genitive month names. For de-DE
the genitive month names are: [Jan., Feb., März, Apr., Mai, Juni, Juli, Aug., Sept., Okt., Nov., Dez., ]
.
This means when formatting a date containing the day as a number (i.e. using d
or dd
in the date pattern), then the genitive names will be used. As you are using the date pattern d.MMM.yyyy
, this means the date will be formatted using the genitive month names. You will get a formatted date something like 1.Jan..2020
. Note the genitive month name here is Jan.
and not Jan
. If you parse back the formatted string 1.Jan..2020
this will be parsed fine. You are not parsing the formatted string instead you are parsing your constructed string 1.Jan.2020
which is not a correct form. If you want to get the result you want with de-DE, you may use something like d.MMMyyyy
or you format with day names instead of day number, like ddd.MMM.yyyy
Description
When trying to parse DateTime values from a string using (Try)ParseExact using culture de-DE, abbreviated month names are not parsed/formatted according to the culture's
DateTimeFormat.AbbreviatedMonthNames
(using format specifier MMM).Reproduction Steps
Demo project can be found here: https://github.com/Jonathan-a35y/dotnet-datetime-bug
Expected behavior
DateTime.ToString and DateTime.Parse should adhere to a culture's
DateTimeFormat.AbbreviatedMonthNames
when parsing/formatting dates using the MMM format specifierActual behavior
DateTime.ToString and DateTime.Parse expect/add periods for some months, for others not.
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response