Designing a culture independent birthdate input consisting of three select: year, month and day.
In .NET, how do I get the correct display order of the three for a given culture, ie.:
┌─────────────┬─┐  ┌──────────────┬─┐  ┌────────────┬─┐
│ Select year │v│  │ Select month │v│  │ Select day │v│  
└─────────────┴─┘  └──────────────┴─┘  └────────────┴─┘
┌─────────────┬─┐  ┌──────────────┬─┐  ┌────────────┬─┐
│ Select day  │v│  │ Select month │v│  │ Select year│v│  
└─────────────┴─┘  └──────────────┴─┘  └────────────┴─┘
or
┌─────────────┬─┐  ┌──────────────┬─┐  ┌────────────┬─┐
│ Select month│v│  │ Select day   │v│  │ Select year│v│  
└─────────────┴─┘  └──────────────┴─┘  └────────────┴─┘
* UPDATE * Thanks to all for your answers, it made me come up with this little function:
  Public Function GetDateElementAtPos(ByVal pos As Integer) As String
    Return Mid(Me.myCultureInfo.DateTimeFormat.ShortDatePattern.Split(Me.myCultureInfo.DateTimeFormat.DateSeparator)(pos), 1, 1).ToLower
  End Function
Where myCultureInfo represents a initialized Globalization.CultureInfo. I use it like this:
Dim s as new stringbuilder
For i As Integer = 0 To 2
  Select Case GetDateElementAtPos(i)
    Case "y"
      s.append(**year select html goes here**)
    Case "m"
      s.append(**month select html goes here**)
    Case "d"
      s.append(**day select html goes here**)
  End Select
Next 
Here you go:
CultureInfo c = ....;
var dtf = c.DateTimeFormat;
var fs = dtf.ShortDatePattern;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With