WinRT(Metro App) - 试图创建GregorianCalendar,JulianCalendar,HebrewCalendar - 找不到名字

时间:2013-01-02 17:35:29

标签: c# calendar visual-studio-2012 microsoft-metro windows-runtime

使用Visual Studio 2012编写Metro应用程序。我正在尝试移植一些我的.NET 2.0代码。我需要创建某些日历的实例来对某些扫描数据进行日期转换。

粗略地说,我只是这样做:

using System.Globalization;

Calendar cal = null;

cal = new GregorianCalendar;

....

cal.GetDaysInMonth(year, month);

但是,日历对象似乎不可用。我花了8个小时的时间在System.Globalization以及Windows.Globalization和找到的东西中寻找解决方法。有没有人有任何建议?

1 个答案:

答案 0 :(得分:1)

优秀。谢谢你的线索。这实际上导致了很好的效果。

第一: 使用Windows.Globalization;

然后: 日历cal =新日历;

随后: cal.ChangeCalendarSystem(CalenderIdentifiers.Gregorian); //(或任何其他人,朱利安,希伯来文,

然后: scratchDateTime = new DateTime(y,m,d,0,0,0,0); //设置年月和日,时间无关紧要 cal.SetDateTime(scratchDateTime); int daysInMonth = cal.NumberOfDaysInThisMonth();