kamagra how much to take

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:

  1.         public static DateTime ConvertSPSystemTimeToDateTime(SPSystemTime st, DateTime refDate)
  2.         {
  3.             if (st.Month == 0)
  4.             {
  5.                 return DateTime.MinValue;
  6.             }
  7.             DateTime time = new DateTime(refDate.Year, st.Month, 1);
  8.             DayOfWeek week = (DayOfWeek) Enum.ToObject(typeof (DayOfWeek), st.DayOfWeek);
  9.             if (time.DayOfWeek > week)
  10.             {
  11.                 time = time.AddDays((7 - (time.DayOfWeek - week)));
  12.             }
  13.             else if (time.DayOfWeek < week)
  14.             {
  15.                 time = time.AddDays((week - time.DayOfWeek));
  16.             }
  17.             time = time.AddDays((7*(st.Day - 1)));
  18.             while (time.Month > st.Month)
  19.             {
  20.                 time = time.AddDays(-7.0);
  21.             }
  22.             return time.Add(new TimeSpan(st.Hour, st.Minute, 0));
  23.         }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>