Converting From SPSystemTime From A Reference Date
If you are working with SPSystemTime struct you will have run into this. Here is a utility method that makes it really easy to get around:
- public static DateTime ConvertSPSystemTimeToDateTime(SPSystemTime st, DateTime refDate)
- {
- if (st.Month == 0)
- {
- return DateTime.MinValue;
- }
- DateTime time = new DateTime(refDate.Year, st.Month, 1);
- DayOfWeek week = (DayOfWeek) Enum.ToObject(typeof (DayOfWeek), st.DayOfWeek);
- if (time.DayOfWeek > week)
- {
- time = time.AddDays((7 - (time.DayOfWeek - week)));
- }
- else if (time.DayOfWeek < week)
- {
- time = time.AddDays((week - time.DayOfWeek));
- }
- time = time.AddDays((7*(st.Day - 1)));
- while (time.Month > st.Month)
- {
- time = time.AddDays(-7.0);
- }
- return time.Add(new TimeSpan(st.Hour, st.Minute, 0));
- }
Articles & Research
SharePoint Security
SharePoint Development
SharePoint Architecture
Claims Authentication
Forefront For SharePoint
AIS / Dynamics GP
Team Foundation Server
Pex And Moles
ISA/TMG/IAG/UAG
DPM
Cardspace
Research Methodology
Rural ICT Development
Numerical Analysis
Multi-Level Research
Knowledge Management
Personal/Off-Topic