问题
nodatime 1.3 released
, but i want to use nodatime
in c#
for Persian date time .
how can i show Persian date time with Noda Time?
var london = DateTimeZoneProviders.Tzdb["Europe/London"];"
What must I do for Persian?
回答1:
You need to explicitly use the Persian calendar.
For example:
var calendar = CalendarSystem.GetPersianCalendar();
var zone = DateTimeZoneProviders.Tzdb["Europe/London"];
var now = SystemClock.Instance.Now.InZone(zone, calendar);
// Now you can get the month, etc.
Or to create a LocalDate
or LocalDateTime
, just pass the calendar as the final argument in the constructor call:
var localDate date = new LocalDate(1393, 4, 17, calendar);
Note that that's using the London time zone in the Persian calendar system. Calendar systems and time zones are very different things. If you want the Tehran time zone, for example, you'd use:
var zone = DateTimeZoneProviders.Tzdb["Asia/Tehran"];
来源:https://stackoverflow.com/questions/24637021/how-to-use-nodatime-for-persian-in-c