public static string getDayInMonth(SYSTEMTIME st) { string sRet = ""; if (st.year != 0) { return(TimeClass.st2dateStr(st)); } //year must be zero //dayOfWeek: 0 = Sun, 1=Mon ... //wDay = 1: first, 2: second, 3: third, 4: fourth, 5: last //ie dayOfWeek=0 => Sunday //wDay = 5 => last dayOfWeek(here=Sunday) in month DateTime dt = new DateTime(DateTime.Now.Year, st.month, 1, st.hour, st.minute, st.second); DateTime dtSavings = new DateTime(); dtSavings = dt; if (st.day == 5) //last occurence of ??? in month { dtSavings = LastDayOfWeekInMonth(dt, (DayOfWeek)(st.dayOfWeek)); } else { int day = DayFinder.FindDay(DateTime.Now.Year, st.month, (DayOfWeek)(st.dayOfWeek), st.day); dtSavings = new DateTime(DateTime.Now.Year, st.month, day, st.hour, st.minute, st.second); } sRet = String.Format("{0:D4}.{1:D2}.{2:D2} {3:D2}:{4:D2}:{5:D2}", dtSavings.Year, dtSavings.Month, dtSavings.Day, dtSavings.Hour, dtSavings.Minute, dtSavings.Second); return(sRet); }
void timer1_Tick(object sender, EventArgs e) { TimeClass.GetSystemTime(out st); systemTimeUC1.setDateTime(st); systemTimeUC1.setType("System Time"); TimeClass.GetLocalTime(out stLocal); systemTimeUC2.setDateTime(stLocal); systemTimeUC2.setType("Local Time"); test(); }
void test() { TimeClass.TimeZoneInformation tzi; int iStatus = TimeClass.GetTimeZoneInformation(out tzi); TimeClass.TIME_ZONE_ID idStatus = (TimeClass.TIME_ZONE_ID)iStatus; txtTZstatus.Text = idStatus.ToString(); txtBias.Text = tzi.bias.ToString(); timeZoneBiasUC1.setInfo(tzi.standardName, tzi.standardDate, tzi.standardBias); timeZoneBiasUC2.setInfo(tzi.daylightName, tzi.daylightDate, tzi.daylightBias); lblAutoDST.Text = TimeClass.isAutoDST() ? "AutoDST is ON" : "AutoDST is OFF"; }
public TimeInfo() { InitializeComponent(); timer1 = new System.Windows.Forms.Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 1000; timer1.Enabled = true; TimeClass.GetSystemTime(out st); systemTimeUC1.setDateTime(st); systemTimeUC1.setType("System Time"); TimeClass.GetLocalTime(out stLocal); systemTimeUC2.setDateTime(stLocal); systemTimeUC2.setType("Local Time"); }
public void setInfo(string name, TimeClass.SYSTEMTIME st, int bias) { txtName.Text = name; txtBias.Text = bias.ToString(); StringBuilder sb = new StringBuilder(); sb.Append(String.Format("({3:D1}) {0:D4}-{1:D2}-{2:D2} {4:D2}:{5:D2}:{6:D2}.{7:D3}", st.year, st.month, st.day, st.dayOfWeek, st.hour, st.minute, st.second, st.milliseconds)); txtSystemTime.Text = sb.ToString(); if (st.year == 0) { //absolute date this year string s = TimeClass.getDayInMonth(st); txtDateTime.Text = s; } else { txtDateTime.Text = txtSystemTime.Text; } }
public void setTime(TimeClass.SYSTEMTIME st) { txtTime.Text = TimeClass.st2TimeStr(st); }
public void setDate(TimeClass.SYSTEMTIME st) { txtDate.Text = TimeClass.st2dateStr(st); }
private void button1_Click(object sender, EventArgs e) { txtLog.Text = TimeClass.DoTZtest(); }