private void NZST(TimeZone t1) { Assert.AreEqual("NZST", t1.StandardName, "E01"); Assert.AreEqual("NZDT", t1.DaylightName, "E02"); DaylightTime d1 = t1.GetDaylightChanges(2013); Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString("G"), "E03"); Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString("G"), "E04"); Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05"); DaylightTime d2 = t1.GetDaylightChanges(2001); Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString("G"), "E06"); Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString("G"), "E07"); Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08"); DateTime d3 = new DateTime(2013, 02, 15); Assert.AreEqual(true, t1.IsDaylightSavingTime(d3), "E09"); DateTime d4 = new DateTime(2013, 04, 30); Assert.AreEqual(false, t1.IsDaylightSavingTime(d4), "E10"); DateTime d5 = new DateTime(2013, 11, 03); Assert.AreEqual(true, t1.IsDaylightSavingTime(d5), "E11"); Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset(d3).Ticks, "E12"); Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset(d4).Ticks, "E13"); Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset(d5).Ticks, "E14"); }
private void GMT(TimeZone t1) { // Probably wont work on MS.NET, but is better than nothing. Where do // we change our implementation to match theirs? Assert.AreEqual("GMT", t1.StandardName, "D01"); Assert.IsTrue("BST" == t1.DaylightName || "IST" == t1.DaylightName, "D02"); DaylightTime d1 = t1.GetDaylightChanges(2002); Assert.AreEqual("03/31/2002 01:00:00", d1.Start.ToString("G"), "D03"); Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString("G"), "D04"); Assert.AreEqual(36000000000L, d1.Delta.Ticks, "D05"); DaylightTime d2 = t1.GetDaylightChanges(1996); Assert.AreEqual("03/31/1996 01:00:00", d2.Start.ToString("G"), "D06"); Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString("G"), "D07"); Assert.AreEqual(36000000000L, d2.Delta.Ticks, "D08"); DateTime d3 = new DateTime(2002, 2, 25); Assert.AreEqual(false, t1.IsDaylightSavingTime(d3), "D09"); DateTime d4 = new DateTime(2002, 4, 2); Assert.AreEqual(true, t1.IsDaylightSavingTime(d4), "D10"); DateTime d5 = new DateTime(2002, 11, 4); Assert.AreEqual(false, t1.IsDaylightSavingTime(d5), "D11"); Assert.AreEqual(0L, t1.GetUtcOffset(d3).Ticks, "D12"); Assert.AreEqual(36000000000L, t1.GetUtcOffset(d4).Ticks, "D13"); Assert.AreEqual(0L, t1.GetUtcOffset(d5).Ticks, "D14"); }
private void EST(TimeZone t1) { Assert.IsTrue("EST" == t1.StandardName || "Eastern Standard Time" == t1.StandardName, "B01"); Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02"); DaylightTime d1 = t1.GetDaylightChanges(2002); Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05"); DaylightTime d2 = t1.GetDaylightChanges(1996); Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08"); DateTime d3 = new DateTime(2002, 2, 25); Assert.AreEqual(false, t1.IsDaylightSavingTime(d3), "B09"); DateTime d4 = new DateTime(2002, 4, 8); Assert.AreEqual(true, t1.IsDaylightSavingTime(d4), "B10"); DateTime d5 = new DateTime(2002, 11, 4); Assert.AreEqual(false, t1.IsDaylightSavingTime(d5), "B11"); Assert.AreEqual(-180000000000L, t1.GetUtcOffset(d3).Ticks, "B12"); Assert.AreEqual(-144000000000L, t1.GetUtcOffset(d4).Ticks, "B13"); Assert.AreEqual(-180000000000L, t1.GetUtcOffset(d5).Ticks, "B14"); // Test TimeZone methods with UTC DateTime in DST. DateTime d6 = d4.ToUniversalTime(); Assert.AreEqual(false, t1.IsDaylightSavingTime(d6), "B15"); Assert.AreEqual(0, t1.GetUtcOffset(d6).Ticks, "B16"); }
private void CET(TimeZone t1) { Assert.AreEqual("CET", t1.StandardName, "A01"); Assert.AreEqual("CEST", t1.DaylightName, "A02"); DaylightTime d1 = t1.GetDaylightChanges(2002); Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString("G"), "A03"); Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString("G"), "A04"); Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05"); DaylightTime d2 = t1.GetDaylightChanges(1996); Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString("G"), "A06"); Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString("G"), "A07"); Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08"); DateTime d3 = new DateTime(2002, 2, 25); Assert.AreEqual(false, t1.IsDaylightSavingTime(d3), "A09"); DateTime d4 = new DateTime(2002, 4, 2); Assert.AreEqual(true, t1.IsDaylightSavingTime(d4), "A10"); DateTime d5 = new DateTime(2002, 11, 4); Assert.AreEqual(false, t1.IsDaylightSavingTime(d5), "A11"); Assert.AreEqual(36000000000L, t1.GetUtcOffset(d3).Ticks, "A12"); Assert.AreEqual(72000000000L, t1.GetUtcOffset(d4).Ticks, "A13"); Assert.AreEqual(36000000000L, t1.GetUtcOffset(d5).Ticks, "A14"); }
private void EST(TimeZone t1) { // It could be EST though... //Assert.AreEqual("Eastern Standard Time", t1.StandardName, "B01"); //Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02"); DaylightTime d1 = t1.GetDaylightChanges(2002); Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString("G"), "B03"); Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString("G"), "B04"); Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05"); DaylightTime d2 = t1.GetDaylightChanges(1996); Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString("G"), "B06"); Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString("G"), "B07"); Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08"); DateTime d3 = new DateTime(2002, 2, 25); Assert.AreEqual(false, t1.IsDaylightSavingTime(d3), "B09"); DateTime d4 = new DateTime(2002, 4, 8); Assert.AreEqual(true, t1.IsDaylightSavingTime(d4), "B10"); DateTime d5 = new DateTime(2002, 11, 4); Assert.AreEqual(false, t1.IsDaylightSavingTime(d5), "B11"); Assert.AreEqual(-180000000000L, t1.GetUtcOffset(d3).Ticks, "B12"); Assert.AreEqual(-144000000000L, t1.GetUtcOffset(d4).Ticks, "B13"); Assert.AreEqual(-180000000000L, t1.GetUtcOffset(d5).Ticks, "B14"); }
public static void TimeDeligth() { TimeZone zone = TimeZone.CurrentTimeZone; WriteLine(zone.StandardName); WriteLine(zone.DaylightName); DateTime dt1 = new DateTime(2020, 1, 1); DateTime dt2 = new DateTime(2020, 6, 1); WriteLine(zone.IsDaylightSavingTime(dt1)); WriteLine(zone.IsDaylightSavingTime(dt2)); WriteLine(zone.GetUtcOffset(dt1)); WriteLine(zone.GetUtcOffset(dt2)); }
/// <summary> /// Gets the text that is written to <see cref="CoreRenderer.Writer" /> before the <see cref="SyntaxTree" /> elements /// are processed by the <see cref="CoreRenderer.Callback" /> delegate. /// </summary> /// <returns> /// An HTML comment that describes when and by what the HTML code was generated as well as the container DIV element for /// the generated HTML. /// </returns> protected override string GetPrefixText() { TracingStopwatch.Start(); TraceWriteLine("Starting HTML rendering at {0:h:mm:ss.ff tt}", DateTime.Now); LineNumber = 1; IsLineEmpty = true; DateTime now = DateTime.Now; TimeZone timeZone = TimeZone.CurrentTimeZone; string timeZoneName = timeZone.IsDaylightSavingTime(now) ? timeZone.DaylightName : timeZone.StandardName; StringBuilder prefixText = new StringBuilder(); prefixText.Append("<!-- HTML was automatically generated by HtmlRenderer on") .AppendFormat(" {0:dddd MMMM d, yyyy a\\t h:mm tt} ({1}) -->", now, timeZoneName) .AppendLine() .AppendLine() .AppendFormat("<div class=\"CodeContainer\">{0}{1,8}{0}{2}", Environment.NewLine, string.Format("<{0}>", ListTagName), GetLineStartText()); return(prefixText.ToString()); }
/// <summary> /// returns build datetime of assembly, using calculated build time if possible, or filesystem time if not /// </summary> private DateTime AssemblyBuildDate(Assembly a, params bool[] values) { bool blnForceFileDate = false; if (values != null && values.Length > 0) { blnForceFileDate = values[0]; } Version v = a.GetName().Version; DateTime dt; if (blnForceFileDate) { dt = AssemblyLastWriteTime(a); } else { dt = new DateTime(2000, 1, 1); dt = dt.AddDays(v.Build).AddSeconds(v.Revision * 2); if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year))) { dt = dt.AddHours(1); } if (dt > DateTime.Now || v.Build < 730 || v.Revision == 0) { dt = AssemblyLastWriteTime(a); } } return(dt); }
// '' <summary> // '' returns build datetime of assembly, using calculated build time if possible, or filesystem time if not // '' </summary> private DateTime AssemblyBuildDate(Assembly a, bool blnForceFileDate = false) { var v = a.GetName().Version; // Warning!!! Optional parameters not supported DateTime dt; if (blnForceFileDate) { dt = AssemblyLastWriteTime(a); } else { dt = DateTime.Parse("01/01/2000").AddDays(v.Build).AddSeconds((v.Revision * 2)); if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year))) { dt = dt.AddHours(1); } if ((dt > DateTime.Now) || (v.Build < 730) || (v.Revision == 0)) { dt = AssemblyLastWriteTime(a); } } return(dt); }
private DateTime ComputeDateTimeTimeZoneLocalDateUtc(TimeSpan value) { if (CurrentDate.Kind != DateTimeKind.Local) { throw new Exception("Invalid CurrentDate DateTimeKind : must be Local"); } var baseUtcOffset = TimeZone.BaseUtcOffset; var dateTime = ComputeNewDateTime(value); if (TimeZone.SupportsDaylightSavingTime) { if (TimeZone.IsAmbiguousTime(dateTime)) { if (IsSummerPeriod) { return(new DateTime(dateTime.AddTicks(-baseUtcOffset.Ticks).AddTicks(-TimeZone.GetAdjustmentRules()[0].DaylightDelta.Ticks).Ticks, DateTimeKind.Utc)); } return(new DateTime(dateTime.AddTicks(-baseUtcOffset.Ticks).Ticks, DateTimeKind.Utc)); } IsSummerPeriod = TimeZone.IsDaylightSavingTime(dateTime); } return(dateTime.ToUniversalTime()); }
private static DateTime AssemblyBuildDate(System.Reflection.Assembly objAssembly, bool bForceFileDate) { System.Version objVersion; DateTime dtBuild; objVersion = objAssembly.GetName().Version; if (bForceFileDate) { dtBuild = AssemblyFileTime(objAssembly); } else { //assuming AssemblyVersion("1.0.*") in assemblyinfo.cs dtBuild = DateTime.Parse("1/1/2000").AddDays(objVersion.Build).AddSeconds(objVersion.Revision * 2); if ( TimeZone.IsDaylightSavingTime( DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year) ) ) { dtBuild.AddHours(1); } if ((dtBuild > DateTime.Now) || (objVersion.Build < 730) || (objVersion.Revision == 0)) { dtBuild = AssemblyFileTime(objAssembly); } } return(dtBuild); }
public void Initialize() { m_dataset = new DataSet(); m_dataset.Tables.Add("FluidLevelTests"); m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string)); m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime)); m_dataset.Tables[0].Columns.Add(BrowseNames.NameWell, typeof(string)); m_dataset.Tables[0].Columns.Add(BrowseNames.UidWell, typeof(string)); m_dataset.Tables[0].Columns.Add(BrowseNames.TestDate, typeof(DateTime)); m_dataset.Tables[0].Columns.Add(BrowseNames.TestReason, typeof(string)); m_dataset.Tables[0].Columns.Add(BrowseNames.FluidLevel, typeof(double)); m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string)); m_dataset.Tables[0].Columns.Add(BrowseNames.TestedBy, typeof(string)); m_dataset.Tables.Add("InjectionTests"); m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string)); m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime)); m_dataset.Tables[1].Columns.Add(BrowseNames.NameWell, typeof(string)); m_dataset.Tables[1].Columns.Add(BrowseNames.UidWell, typeof(string)); m_dataset.Tables[1].Columns.Add(BrowseNames.TestDate, typeof(DateTime)); m_dataset.Tables[1].Columns.Add(BrowseNames.TestReason, typeof(string)); m_dataset.Tables[1].Columns.Add(BrowseNames.TestDuration, typeof(double)); m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string)); m_dataset.Tables[1].Columns.Add(BrowseNames.InjectedFluid, typeof(string)); m_random = new Random(); // look up the local timezone. TimeZone timeZone = TimeZone.CurrentTimeZone; m_timeZone = new TimeZoneDataType(); m_timeZone.Offset = (short)timeZone.GetUtcOffset(DateTime.Now).TotalMinutes; m_timeZone.DaylightSavingInOffset = timeZone.IsDaylightSavingTime(DateTime.Now); }
private static DateTime AssemblyBuildDate(Assembly parentAssembly) { try { Version v = parentAssembly.GetName().Version; DateTime buildDate = new DateTime(2000, 1, 1).AddDays(v.Build).AddSeconds(v.Revision * 2); if (TimeZone.IsDaylightSavingTime(DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year))) { buildDate = buildDate.AddHours(1); } if (buildDate > DateTime.Now || v.Build < 730 || v.Revision == 0) { buildDate = AssemblyFileTime(parentAssembly); } return(buildDate); } catch { return(DateTime.MinValue); } }
public static DateTime AssemblyBuildDate(Assembly assembly, bool forceFileDate = false) { Version version = assembly.GetName().Version; DateTime build; if (forceFileDate) { return(AssemblyFileTime(assembly)); } else { build = DateTime.Parse("01/01/2000").AddDays(version.Build).AddSeconds(version.Revision * 2); if (TimeZone.IsDaylightSavingTime(DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year))) { build = build.AddHours(1); } if (build > DateTime.Now || version.Build < 730 || version.Revision == 0) { build = AssemblyFileTime(assembly); } } return(build); }
protected static DateTime GetAssemblyBuildDate(Assembly asm, bool forceFileDate) { Version ver = asm.GetName().Version; DateTime result; if (forceFileDate) { result = GetAssemblyFileTime(asm); } else { result = new DateTime(2000, 1, 1).AddDays(ver.Build).AddSeconds(ver.Revision * 2); if (TimeZone.IsDaylightSavingTime(result, TimeZone.CurrentTimeZone.GetDaylightChanges(result.Year))) { result = result.AddHours(1); } if (result > DateTime.Now || ver.Build < 730 || ver.Revision == 0) { result = GetAssemblyFileTime(asm); } } return(result); }
/// <summary> /// Returns build datetime of assembly. Assumes default assembly value in AssemblyInfo. Filesystem create time is used, if revision and build were overridden by user. /// </summary> /// <param name="a"></param> /// <param name="forceFileDate"></param> /// <returns></returns> private static DateTime?GetAssemblyBuildDate(Assembly a, bool forceFileDate) { Version version = a.GetName().Version; DateTime buildDate = default(DateTime); if (forceFileDate) { return(GetAssemblyFileTime(a)); } else { buildDate = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2); if (TimeZone.IsDaylightSavingTime(DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year))) { buildDate = buildDate.AddHours(1); } if (buildDate > DateTime.Now | version.Build < 730 | version.Revision == 0) { return(GetAssemblyFileTime(a)); } } return(buildDate); }
protected virtual int GetCurrentTimeResponse(DataTable table) { if (table.Rows.Count == 1) { serverTime = ((DateTime)table.Rows[0][0]).Add(m_tsOffsetToMoscow); } else { DaylightTime daylight = TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year); int timezone_offset = allTECComponents[indxTECComponents].tec.m_timezone_offset_msc; if (TimeZone.IsDaylightSavingTime(DateTime.Now, daylight) == true) { timezone_offset++; } else { ; } //serverTime = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now).AddHours(3); //serverTime = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now).AddHours(timezone_offset); serverTime = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now).AddHours(allTECComponents[indxTECComponents].tec.m_timezone_offset_msc); ErrorReport("Ошибка получения текущего времени сервера. Используется локальное время."); } return(0); }
/// <summary> /// returns DateTime this Assembly was last built. Will attempt to calculate from build number, if possible. /// If not, the actual LastWriteTime on the assembly file will be returned. /// </summary> /// <param name="a">Assembly to get build date for</param> /// <param name="forceFileDate">Don't attempt to use the build number to calculate the date</param> /// <returns>DateTime this assembly was last built</returns> private DateTime AssemblyBuildDate(Assembly a, bool forceFileDate) { Version assemblyVersion = a.GetName().Version; DateTime dt; if (forceFileDate) { dt = AssemblyLastWriteTime(a); } else { dt = DateTime.Parse("01/01/2000").AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2); if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year))) { dt = dt.AddHours(1); } if (dt > DateTime.Now || assemblyVersion.Build < 730 || assemblyVersion.Revision == 0) { dt = AssemblyLastWriteTime(a); } } return(dt); }
private void SetTimeToGPS(DateTime UTCtime) { if (m_SetTime) { // Get the local time zone and a base Coordinated Universal // Time (UTC). TimeZone localZone = TimeZone.CurrentTimeZone; DateTime baseUTC = UTCtime; // new DateTime(2000, 1, 1); System.Diagnostics.Debug.WriteLine("\nLocal time: {0}\n", localZone.StandardName); // Calculate the local time and UTC offset. DateTime localTime = localZone.ToLocalTime(baseUTC); TimeSpan localOffset = localZone.GetUtcOffset(localTime); System.Diagnostics.Debug.WriteLine(string.Format("{0,-20:yyyy-MM-dd HH:mm}" + "{1,-20:yyyy-MM-dd HH:mm}{2,-12}{3}", baseUTC, localTime, localOffset, localZone.IsDaylightSavingTime(localTime))); //adjust the clock //localTime += localOffset; PInvokeLibrary.SystemTimeLib.SetTime(localTime); m_SetTime = false; } }
public DateTime GetBuildDataTime(Version oVersion) { string strVerstion = oVersion.ToString(); // 날짜 등록 int iDays = Convert.ToInt32(strVerstion.Split('.')[2]); DateTime refData = new DateTime(2000, 1, 1); DateTime dtBuildDate = refData.AddDays(iDays); // 초 등록 int iSeconds = Convert.ToInt32(strVerstion.Split('.')[3]); iSeconds = iSeconds * 2; dtBuildDate = dtBuildDate.AddSeconds(iSeconds); // 시차 조정 DaylightTime daylighttime = TimeZone.CurrentTimeZone.GetDaylightChanges(dtBuildDate.Year); if (TimeZone.IsDaylightSavingTime(dtBuildDate, daylighttime)) { dtBuildDate = dtBuildDate.Add(daylighttime.Delta); } return(dtBuildDate); }
// <summary> // returns DateTime this Assembly was last built. Will attempt to calculate from build number, if possible. // If not, the actual LastWriteTime on the assembly file will be returned. // </summary> // <param name="a">Assembly to get build date for</param> // <param name="ForceFileDate">Don't attempt to use the build number to calculate the date</param> // <returns>DateTime this assembly was last built</returns> private DateTime AssemblyBuildDate(Assembly a, bool ForceFileDate) { var lastWrite = new Func <Assembly, DateTime>((ass) => { if (ass.Location == null || ass.Location == "") { return(DateTime.MaxValue); } try{ return(File.GetLastWriteTime(ass.Location)); }catch (Exception) { } return(DateTime.MaxValue); }); Version AssemblyVersion = a.GetName().Version; DateTime dt; if (ForceFileDate) { dt = lastWrite(a); } else { dt = DateTime.Parse("01/01/2000").AddDays(AssemblyVersion.Build).AddSeconds(AssemblyVersion.Revision * 2); if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year))) { dt = dt.AddHours(1); } if (dt > DateTime.Now || AssemblyVersion.Build < 730 || AssemblyVersion.Revision == 0) { dt = lastWrite(a); } } return(dt); }
//어셈블리 버전 정보로 현재날짜와 시간 가져옴 public DateTime GetBuildDataTime(Version oVersion) { string strVerstion = oVersion.ToString(); // 날짜 등록 int iDays = Convert.ToInt32(strVerstion.Split('.')[2]); //버전 3번째 항목 7095 DateTime refData = new DateTime(2000, 1, 1); //2000년1월1일에 + 버전 3번재 항목 더하면 DateTime dtBuildDate = refData.AddDays(iDays); //오늘날짜 찍힘 {2019-06-05 수 오전 12:00:00} // 초 등록 int iSeconds = Convert.ToInt32(strVerstion.Split('.')[3]); iSeconds = iSeconds * 2; // dtBuildDate = dtBuildDate.AddSeconds(iSeconds); //오늘날짜 시간까지 제대로 찍힘 {2019-06-05 수 오후 10:21:48} // 시차 조정(이거 잘 안쓸듯,,?) DaylightTime daylighttime = TimeZone.CurrentTimeZone.GetDaylightChanges(dtBuildDate.Year); if (TimeZone.IsDaylightSavingTime(dtBuildDate, daylighttime)) { dtBuildDate = dtBuildDate.Add(daylighttime.Delta); } return(dtBuildDate); //{2019-06-05 수 오후 10:21:48} }
//-- //-- returns build datetime of assembly //-- assumes default assembly value in AssemblyInfo: //-- <Assembly: AssemblyVersion("1.0.*")> //-- //-- filesystem create time is used, if revision and build were overridden by user //-- private static DateTime AssemblyBuildDate(System.Reflection.Assembly objAssembly, bool blnForceFileDate = false) { System.Version objVersion = objAssembly.GetName().Version; DateTime dtBuild = default(DateTime); if (blnForceFileDate) { dtBuild = AssemblyFileTime(objAssembly); } else { //dtBuild = ((DateTime)"01/01/2000").AddDays(objVersion.Build).AddSeconds(objVersion.Revision * 2); dtBuild = Convert.ToDateTime("01/01/2000").AddDays((double)objVersion.Build).AddSeconds((double)(objVersion.Revision * 2)); if (TimeZone.IsDaylightSavingTime(DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year))) { dtBuild = dtBuild.AddHours(1); } if (dtBuild > DateTime.Now | objVersion.Build < 730 | objVersion.Revision == 0) { dtBuild = AssemblyFileTime(objAssembly); } } return(dtBuild); }
private void Page_Load(object sender, EventArgs e) { mandatorName = BLL.Mandator.MandatorName; mandatorSiteTitle = BLL.Mandator.SiteTitle; mandatorSmsCredit = (BLL.Mandator.SmsPurchased - BLL.Mandator.SmsLog).ToString(); MandatorSmsCreditRow.Visible = BLL.Mandator.SmsNotifications; // version of web assembly Assembly assembly = Assembly.GetExecutingAssembly(); Version assemblyVersion = assembly.GetName().Version; version = String.Format("{0}.{1}.{2}", assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build); assemblyName = assembly.GetName().Name; DateTime dt = DateTime.Parse("01.01.2000"); dt = dt.AddDays(assemblyVersion.Build); dt = dt.AddSeconds(assemblyVersion.Revision * 2); if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year))) { dt = dt.AddHours(1); } if (dt > DateTime.Now || assemblyVersion.Build < 730 || assemblyVersion.Revision == 0) { dt = File.GetLastWriteTime(assembly.Location); } buildDate = dt.ToLongDateString() + " " + dt.ToLongTimeString(); }
public SetupDialogForm() { InitializeComponent(); Version version = Assembly.GetExecutingAssembly().GetName().Version; labelVersion.Text = string.Format(CultureInfo.CurrentCulture, "ASCOM Telescope Simulator .NET Version {0}.{1}.{2}", version.Major, version.Minor, version.Build); TimeZone localZone = TimeZone.CurrentTimeZone; labelTime.Text = "Time zone is " + localZone.StandardName; if (localZone.IsDaylightSavingTime(DateTime.Now)) { labelTime.Text += " (currently DST)"; } //This is a little silly, but you cant build a combobox with values without a datasource //I would get confused trying to decifer the original logic if I didnt set the values the same Collection <ComboBoxItem> items = new Collection <ComboBoxItem>(); ComboBoxItem item1 = new ComboBoxItem(); item1.Display = "Local"; item1.Value = "1"; ComboBoxItem item2 = new ComboBoxItem(); item2.Display = "B1950"; item2.Value = "4"; ComboBoxItem item3 = new ComboBoxItem(); item3.Display = "J2000"; item3.Value = "2"; ComboBoxItem item4 = new ComboBoxItem(); item4.Display = "J2050"; item4.Value = "3"; ComboBoxItem item5 = new ComboBoxItem(); item5.Display = "Other"; item5.Value = "0"; items.Add(item1); items.Add(item2); items.Add(item3); items.Add(item4); items.Add(item5); comboBoxEquatorialSystem.DataSource = items; comboBoxEquatorialSystem.DisplayMember = "Display"; comboBoxEquatorialSystem.ValueMember = "Value"; // Local,1 // B1950,4 // J2000,2 // J2050,3 // Other,0 }
public DateTime AdjustForDayLightSavingsBug(DateTime date) { if (currentTimeZone.IsDaylightSavingTime(DateTime.Now)) { TimeSpan anHour = new TimeSpan(1, 0, 0); return(date.Subtract(anHour)); } return(date); }
public static void TestOffsetsAndDaylight() { var currentZone = TimeZone.CurrentTimeZone; DateTime now = DateTime.Now; Assert.Equal(TimeZoneInfo.Local.GetUtcOffset(now), currentZone.GetUtcOffset(now)); Assert.Equal(TimeZoneInfo.Local.IsDaylightSavingTime(now), currentZone.IsDaylightSavingTime(now)); Assert.Equal(TimeZoneInfo.Local.IsDaylightSavingTime(now), TimeZone.IsDaylightSavingTime(now, currentZone.GetDaylightChanges(now.Year))); }
private void TST(TimeZone t1) { Assert.AreEqual("Tokyo Standard Time", t1.StandardName, "C01"); Assert.AreEqual("Tokyo Standard Time", t1.DaylightName, "C02"); DateTime d3 = new DateTime(2002, 2, 25); Assert.AreEqual(false, t1.IsDaylightSavingTime(d3), "C09"); DateTime d4 = new DateTime(2002, 4, 8); Assert.AreEqual(false, t1.IsDaylightSavingTime(d4), "C10"); DateTime d5 = new DateTime(2002, 11, 4); Assert.AreEqual(false, t1.IsDaylightSavingTime(d5), "C11"); Assert.AreEqual(324000000000L, t1.GetUtcOffset(d3).Ticks, "C12"); Assert.AreEqual(324000000000L, t1.GetUtcOffset(d4).Ticks, "C13"); Assert.AreEqual(324000000000L, t1.GetUtcOffset(d5).Ticks, "C14"); }
internal string generateHeader() { DateTime fileCreated = DateTime.Now; DateTime fileCreated_GMT = fileCreated.ToUniversalTime(); string GMTOffset; if (fileCreated.Hour - fileCreated_GMT.Hour < 0) { GMTOffset = String.Format("{0:00}", fileCreated.Hour - fileCreated_GMT.Hour) + "00"; } else { GMTOffset = String.Format("{0:+00}", fileCreated.Hour - fileCreated_GMT.Hour) + "00"; } TimeZone localZone = TimeZone.CurrentTimeZone; string timeZone; if (localZone.IsDaylightSavingTime(fileCreated)) { timeZone = localZone.DaylightName; } else { timeZone = localZone.StandardName; } string mainHeader = @";DynamoPancakeBot GCODE header start" + "\r\n" + ";Originally generated @ " + DateTime.Now.ToString("ddd MMM dd yyyy HH:mm:ss") + " GMT" + GMTOffset + " (" + timeZone + ")" + "\r\n" + ";Settings used to generate this file:" + "\r\n" + ";----------------------------------------\r\n" + ";botSpeed: " + botSpeed + "\r\n" + ";lineEndPreShutoff: " + lineEndPreShutoff + "\r\n" + ";startWait: " + startWait + "\r\n" + ";endWait: " + endWait + "\r\n" + ";shadeChangeWait: " + shadeChangeWait + "\r\n" + ";useLineFill: " + useLineFill + "\r\n" + ";shapeFillWidth: " + shapeFillWidth + "\r\n" + ";fillSpacing: " + fillSpacing + "\r\n" + ";fillAngle: " + fillAngle + "\r\n" + ";fillGroupThreshold: " + fillGroupThreshold + "\r\n" + ";useColorSpeed: " + useColorSpeed + "\r\n" + ";botColorSpeed: " + botColorSpeed[0] + "," + botColorSpeed[1] + "," + botColorSpeed[2] + "," + botColorSpeed[3] + "\r\n" + ";----------------------------------------" + "\r\n" + "W1 X42 Y210 L485 T0 ;Define Workspace of this file" + "\r\n" + "G21 ;Set units to MM" + "\r\n" + "G1 F4620 ;Set Speed" + "\r\n" + "M107 ;Pump off" + "\r\n" + "G4 P1000 ;Pause for 1000 milliseconds" + "\r\n" + "M84 ;Motors off" + "\r\n" + "G00 X1 Y1 ;Help homing" + "\r\n" + "G28 X0 Y0 ;Home All Axis" + "\r\n" + ";PancakePainter header complete"; return(mainHeader); }
private void TimeZoneExample() { Console.WriteLine("\nTime Zone Example:"); TimeZone currentZone = TimeZone.CurrentTimeZone; TimeZoneInfo pacific = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); Console.WriteLine(currentZone.StandardName + " || " + currentZone.DaylightName); Console.WriteLine(pacific.StandardName + " " + pacific.BaseUtcOffset); DateTime dt1 = new DateTime(2008, 1, 1); DateTime dt2 = new DateTime(2010, 5, 22); Console.WriteLine("IS DAYlight Saving Time:"); Console.WriteLine(currentZone.IsDaylightSavingTime(dt1)); Console.WriteLine(currentZone.IsDaylightSavingTime(dt2)); Console.WriteLine("Current Zone..."); Console.WriteLine(dt1 + " --- " + currentZone.GetUtcOffset(dt1)); Console.WriteLine(dt2 + " --- " + currentZone.GetUtcOffset(dt2)); }