Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SYSTEMTIME (Structures)
 
.
Summary
Represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.

C# Definition:

[Serializable, StructLayout(LayoutKind.Sequential)]
public struct SYSTEMTIME
{
   [MarshalAs(UnmanagedType.U2)] public short Year;
   [MarshalAs(UnmanagedType.U2)] public short Month;
   [MarshalAs(UnmanagedType.U2)] public short DayOfWeek;
   [MarshalAs(UnmanagedType.U2)] public short Day;
   [MarshalAs(UnmanagedType.U2)] public short Hour;
   [MarshalAs(UnmanagedType.U2)] public short Minute;
   [MarshalAs(UnmanagedType.U2)] public short Second;
   [MarshalAs(UnmanagedType.U2)] public short Milliseconds;

   public SYSTEMTIME(short year, short month, short dayOfWeek, short day, short, hour, short minute, short second, short milliseconds)
   {
     this.Year = year;
     this.Month = month;
     this.DayOfWeek = dayOfWeek;
     this.Day = day;
     this.Hour = hour;
     this.Minute = minute;
     this.Second = second;
     this.Milliseconds = milliseconds;
   }

   public DateTime ToDateTime()
   {
     if (Year == 0)
       return DateTime.MinValue;

     return new DateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds);
   }

   public static SYSTEMTIME FromDateTime(DateTime dateTime)
   {
     return new SYSTEMTIME((short)dateTime.Year, (short)dateTime.Month, (short)dateTime.DayOfWeek, (short)dateTime.Day, (short)dateTime.Hour, (short)dateTime.Minute, (short)dateTime.Second, (short)dateTime.Millisecond);
   }
}

VB Definition:

<Serializable, StructLayout(LayoutKind.Sequential)>
Public Class SYSTEMTIME
   <MarshalAs(UnmanagedType.U2)> Public Year As Short
   <MarshalAs(UnmanagedType.U2)> Public Month As Short
   <MarshalAs(UnmanagedType.U2)> Public DayOfWeek As Short
   <MarshalAs(UnmanagedType.U2)> Public Day As Short
   <MarshalAs(UnmanagedType.U2)> Public Hour As Short
   <MarshalAs(UnmanagedType.U2)> Public Minute As Short
   <MarshalAs(UnmanagedType.U2)> Public Second As Short
   <MarshalAs(UnmanagedType.U2)> Public Milliseconds As Short
End Class

Notes:

None.

Tips & Tricks:

Please add some!

Documentation
SYSTEMTIME on MSDN

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions