SDF 2.0 continues to have functionality for working with the time and time zones for devices. The differences from SDF 1.x are a namespace change, a classname change (don't believe the beta docs or the beta, these have changed since that drop), and under the hood a lot more internal checks are going on to head off errors and to provide correct device support. Basically this one has been pretty heavily tested across a broad range of devices.
Some quick highlights:
Getting and Displaying a List of Time Zones
using OpenNETCF.WindowsCE;
...
// get and display all available zones
TimeZoneCollection tzc = new TimeZoneCollection();
tzc.Initialize();
foreach (TimeZoneInformation tzi in tzc)
{
lstZones.Items.Add(tzi);
}
Displaying the Currently Set Time Zone
using OpenNETCF.WindowsCE;
...
// get and display the currrent zone
TimeZoneInformation currentTz = new TimeZoneInformation();
DateTimeHelper.GetTimeZoneInformation(ref currentTz);
lblCurrentZone.Text = currentTz.StandardName;
Setting the Current Time Zone (from the Listing above)
using OpenNETCF.WindowsCE;
...
if (lstZones.SelectedItem != null)
{
TimeZoneInformation tzi = (TimeZoneInformation)lstZones.SelectedItem;
DateTimeHelper.SetTimeZoneInformation(tzi);
// this verifies that the time zone did indeed get changed
TimeZoneInformation tz = new TimeZoneInformation(
(byte[])Registry.LocalMachine.OpenSubKey("Time").GetValue(
"TimeZoneInformation"));
MessageBox.Show("Current Timezone in Registry is:\r\n"
+ tz.StandardName, "Verified");
}
Displaying the Current Time (without DateTime.Now)
using OpenNETCF.WindowsCE;
...
DateTime dt = DateTimeHelper.SystemTime;
txtHour.Text = dt.Hour.ToString();
txtMinute.Text = string.Format("{0:00}", dt.Minute);
txtSecond.Text = string.Format("{0:00}", dt.Second);
Setting The Current System Time (Local Time is Analogous)
using OpenNETCF.WindowsCE;
...
// get the current time so we can copy the date part
DateTime dt = DateTimeHelper.SystemTime;
DateTimeHelper.SystemTime = new DateTime(dt.Year, dt.Month, dt.Day,
int.Parse(txtHour.Text), int.Parse(txtMinute.Text), int.Parse(txtSecond.Text));