Friday, December 17, 2010

Studying F# : Local Calendars #2

(continued from phosphorescence: Studying F# : Local Calendars)

In previous article, I try to retrieve System.DateTime with local calendar. And in this article, I try to display the date and its local era with local calendar in local "culture". In .NET/CLR terminology, "culture" is equivalent with "locale".

> open System;;
> open System.Globalization;;
> let japanInfo = new CultureInfo("ja-JP");;

val japanInfo : CultureInfo = ja-JP

> japanInfo.DateTimeFormat.Calendar <- new JapaneseCalendar();;
val it : unit = ()
> DateTime.Now.ToString("D", japanInfo);;
val it : string = "平成 22年12月17日"

"平成" is the era pronouncing "Heisei".

No comments:

Post a Comment