当前位置: 首页>>代码示例>>C#>>正文


C# DateTime.AddMilliseconds方法代码示例

本文整理汇总了C#中System.DateTime.AddMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.AddMilliseconds方法的具体用法?C# DateTime.AddMilliseconds怎么用?C# DateTime.AddMilliseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.AddMilliseconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: read

		public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext )
		{
            double dateTime = reader.ReadDouble();
            // ignore the stupid timezone
            reader.ReadUnsignedShort();

            DateTime sent = new DateTime( 1970, 1, 1 );

#if (FULL_BUILD || PURE_CLIENT_LIB )
            // get the offset of the time zone the server is in
            double localTimezoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset( sent ).TotalMilliseconds;
            // convert 1/1/1970 12AM to UTC
            sent = TimeZone.CurrentTimeZone.ToUniversalTime( sent );
#else
            double localTimezoneOffset = TimeZoneInfo.Local.GetUtcOffset( sent ).TotalMilliseconds;
            sent = TimeZoneInfo.ConvertTime( sent, TimeZoneInfo.Utc );
#endif
            
            // bring it back to 12AM
            sent = sent.AddMilliseconds( localTimezoneOffset );

            // now that the sent object is in UTC and it represents 1/1/1970 12AM
            // convert it to the time sent by the client. The result of the operation
            // is going to be client's datetime object in UTC
            sent = sent.AddMilliseconds( dateTime );

            return new DateType( sent );
		}	
开发者ID:Georotzen,项目名称:.NET-SDK-1,代码行数:28,代码来源:DateReader.cs

示例2: Count

        public int[] Count(string query, DateTime rangeFrom, DateTime rangeTo, int timeSlices, string groupBy)
        {
            int[] result = new int[timeSlices];

            TimeSpan rangeDuration = rangeTo.Subtract(rangeFrom);
            int timeSliceDuration = (int)rangeDuration.TotalMilliseconds / timeSlices;

            for (int timeSlice = 0; timeSlice < timeSlices; timeSlice++)
            {
                EAEPMessages messages = store.GetMessages(
                    rangeFrom.AddMilliseconds(timeSlice * timeSliceDuration),
                    rangeFrom.AddMilliseconds((timeSlice + 1) * timeSliceDuration),
                    query);

                if (groupBy != null)
                {
                    HashSet<string> groups = new HashSet<string>();

                    foreach (EAEPMessage message in messages)
                    {
                        if (message.ContainsParameter(groupBy) && !groups.Contains(message[groupBy]))
                        {
                            groups.Add(message[groupBy]);
                        }
                    }

                    result[timeSlice] = groups.Count;
                }
                else
                {
                    result[timeSlice] = messages.Count;
                }
            }
            return result;
        }
开发者ID:adambird,项目名称:eaep,代码行数:35,代码来源:Aggregator.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            AccountInfo cu = ServerImpl.Instance.GetCurrentUser(Context);
            if (cu == null || !cu.IsAdmin) throw new Exception("你没有权限访问该页面!");

            if (IsPostBack)
            {
                switch (Request.Params["command"])
                {
                case "Delete":
                    {
                        Core.MessageImpl.Instance.DeleteMessages(Request.Params["data"]);
                        break;
                    }
                }
            }

            DateTime from, to, baseDate = new DateTime(1900, 1, 1);

            from = Request.QueryString["From"] == null ? new DateTime(1900, 1, 1) : baseDate.AddMilliseconds(Convert.ToInt32(Request.QueryString["From"]));
            to = Request.QueryString["To"] == null ? new DateTime(2100, 1, 1) : baseDate.AddMilliseconds(Convert.ToInt32(Request.QueryString["To"]));

            Int32 pageSize = 15;
            Int32 user = Request.QueryString["User"] == null ? 0 : Convert.ToInt32(Request.QueryString["User"]);
            Int32 peer = Request.QueryString["Peer"] == null ? 0 : Convert.ToInt32(Request.QueryString["Peer"]);
            int msgId = 0;
            if (Request.QueryString["CurrentPage"] != null)
            {
                _currentPage = Convert.ToInt32(Request.QueryString["CurrentPage"]);
                msgId = 0;
            }
            else
            {
                _currentPage = -1;
                msgId = Request.QueryString["MsgID"] == null ? 0 : Convert.ToInt32(Request.QueryString["MsgID"]);
            }

            Core.MessageImpl.Instance.WriteCache();

            DataTable msgs = null;
            if (peer > 0) msgs = Core.MessageImpl.Instance.GetUserMessages(user, peer, from, to, pageSize, ref _currentPage, out _pageCount, msgId);
            else msgs = Core.MessageImpl.Instance.GetGroupMessages(user, from, to, pageSize, ref _currentPage, out _pageCount, msgId);

            foreach (DataRow row in msgs.Rows)
            {
                Message_MessageCtrl ctrl = LoadControl("MessageCtrl.ascx") as Message_MessageCtrl;
                ctrl.Data = row;
                FindControl("MsgContainer").Controls.Add(ctrl);
            }
        }
开发者ID:cyyt,项目名称:Lesktop,代码行数:50,代码来源:ViewMessages.aspx.cs

示例4: TestGetFireTimeAfter

        public void TestGetFireTimeAfter()
        {
            DateTimeOffset startCalendar = new DateTime(2005, 6, 1, 9, 30, 17);

            // Test yearly
            NthIncludedDayTrigger yearlyTrigger = new NthIncludedDayTrigger();
            yearlyTrigger.IntervalType = NthIncludedDayTrigger.IntervalTypeYearly;
            yearlyTrigger.StartTimeUtc = startCalendar;
            yearlyTrigger.N = 10;
            yearlyTrigger.FireAtTime = "14:35:15";

            DateTimeOffset targetCalendar = new DateTime(2006, 1, 10, 14, 35, 15).ToUniversalTime();
            DateTimeOffset? nextFireTimeUtc;

            nextFireTimeUtc = yearlyTrigger.GetFireTimeAfter(startCalendar.AddMilliseconds(1000));
            Assert.AreEqual(targetCalendar, nextFireTimeUtc.Value);

            // Test monthly
            NthIncludedDayTrigger monthlyTrigger = new NthIncludedDayTrigger();
            monthlyTrigger.IntervalType = NthIncludedDayTrigger.IntervalTypeMonthly;
            monthlyTrigger.StartTimeUtc = startCalendar;
            monthlyTrigger.N = 5;
            monthlyTrigger.FireAtTime = "14:35:15";

            targetCalendar = new DateTime(2005, 6, 5, 14, 35, 15).ToUniversalTime();
            nextFireTimeUtc = monthlyTrigger.GetFireTimeAfter(startCalendar.AddMilliseconds(1000));
            Assert.AreEqual(targetCalendar, nextFireTimeUtc.Value);

            // Test weekly
            NthIncludedDayTrigger weeklyTrigger = new NthIncludedDayTrigger();
            weeklyTrigger.IntervalType = NthIncludedDayTrigger.IntervalTypeWeekly;
            weeklyTrigger.StartTimeUtc = startCalendar;
            weeklyTrigger.N = 3;
            weeklyTrigger.FireAtTime = "14:35:15";

            //roll start date forward to first day of the next week
            while (startCalendar.DayOfWeek != DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek)
            {
                startCalendar = startCalendar.AddDays(1);
            }

            //calculate expected fire date
            targetCalendar = new DateTime(startCalendar.Year, startCalendar.Month, startCalendar.Day, 14, 35, 15);

            //first day of the week counts as one. add two more to get N=3.
            targetCalendar = targetCalendar.AddDays(2);

            nextFireTimeUtc = weeklyTrigger.GetFireTimeAfter(startCalendar.AddMilliseconds(1000));
            Assert.AreEqual(targetCalendar.ToUniversalTime(), nextFireTimeUtc.Value);
        }
开发者ID:nunomaia,项目名称:quartznet,代码行数:50,代码来源:NthIncludedDayTriggerTest.cs

示例5: SetSpeed

 /// <summary>
 /// Set the desired speed of the wheel, and the time to take to get there (ease-in).
 /// If time is zero, the specified speed will be set on the next update.
 /// If time is non-zero, the speed will be reached in the specified time with a simple linear accelleration.
 /// </summary>
 /// <remarks>No changes are actually applied to the wheel until <see cref="update"/> is called.</remarks>
 /// <param name="speed">Target speed</param>
 /// <param name="time">Time to reach speed (millis)</param>
 public void SetSpeed(int speed, ulong time = 0)
 {
     SpeedRequestedAt = DateTime.Now;
     SpeedRequestedFor = SpeedRequestedAt.AddMilliseconds(time);
     RequestedStartSpeed = CurrentSpeed;
     RequestedTargetSpeed = Tools.Constrain(speed, -100, 100);
 }
开发者ID:Cylindric,项目名称:Bot,代码行数:15,代码来源:Wheel.cs

示例6: ToDateTime

        public static DateTime ToDateTime(long ticks)
        {
            DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime dateTime = start.AddMilliseconds(ticks).ToLocalTime();

            return dateTime;
        }
开发者ID:rjabaker,项目名称:Skynet,代码行数:7,代码来源:DateTimeUtilities.cs

示例7: UnixTimeStampToDateTime

 public static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
 {
     // Unix timestamp is seconds past epoch
     System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
     dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();
     return dtDateTime;
 }
开发者ID:JohniFx,项目名称:lmax,代码行数:7,代码来源:HistoricData.cs

示例8: IncrementDate

        public static DateTime IncrementDate(this TimePeriod period, DateTime date, int amount)
        {
            switch (period) {
                case TimePeriod.Millisecond:
                    return date.AddMilliseconds(amount);
                case TimePeriod.Second:
                    return date.AddSeconds(amount);
                case TimePeriod.Minute:
                    return date.AddMinutes(amount);
                case TimePeriod.Hour:
                    return date.AddHours(amount);
                case TimePeriod.Day:
                    return date.AddDays(amount);
                case TimePeriod.Month:
                    return date.AddMonths(amount);
                case TimePeriod.Quarter:
                    return date.AddMonths(amount * 3);
                case TimePeriod.Half:
                    return date.AddMonths(amount * 6);
                case TimePeriod.Year:
                    return date.AddYears(amount);

                default:
                    throw new Exception("Unknown period: " + period.ToString());

            }
        }
开发者ID:GrowingData,项目名称:Mung,代码行数:27,代码来源:TimePeriod.cs

示例9: Convert

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      if (value == null)
        return "";

      double milliSecs = 0;
      if (!double.TryParse(value.ToString(), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out milliSecs))
        return "";

      //unix epoch, UTC (also known as GMT)
      System.DateTime date = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

      //add the specified milliseconds
      date = date.AddMilliseconds(milliSecs);

      //time stamp is UTC (also known as GMT) -> convert to local time zone
      date = TimeZoneInfo.ConvertTime(date, TimeZoneInfo.Local);

      //return a culture-specific formatted date

      // Get the format string for the current UI culture
      string dateFormatString = CultureInfo.CurrentUICulture.DateTimeFormat.FullDateTimePattern;

      // Remove day and seconds from format string
      dateFormatString = Util.RemoveDayFormat(dateFormatString);
      dateFormatString = dateFormatString.Replace(":ss", "");

      // Replace two digit day with single digit
      dateFormatString = dateFormatString.Replace("dd", "d");

       // Trim leading and trailing whitespace
      dateFormatString = dateFormatString.Trim();

        return date.ToString(dateFormatString, CultureInfo.CurrentUICulture);
    }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:35,代码来源:ValueConverters.cs

示例10: UnixTimeConverter

        public static DateTime UnixTimeConverter(double unx)
        {
            DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            dateTime = dateTime.AddMilliseconds(unx).ToLocalTime();

            return dateTime;
        }
开发者ID:pl12133,项目名称:WeatherSpot,代码行数:7,代码来源:PlottingClass.cs

示例11: convertUnixTimeStampToDateTime

 private static DateTime convertUnixTimeStampToDateTime(double unixTimeStamp)
 {
     // Unix timestamp is seconds past epoch
     System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
     dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();
     return dtDateTime;
 }
开发者ID:Yabko,项目名称:jUtils,代码行数:7,代码来源:JRow.cs

示例12: ReadJson

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            double microseconds = (long)reader.Value / 1000.0;

            DateTime dateTime = new DateTime(1970, 1, 1);
            return dateTime.AddMilliseconds(microseconds);
        }
开发者ID:pieterderycke,项目名称:CloudFox,代码行数:7,代码来源:DateTimeJsonConverter.cs

示例13: Check

        public override NodeResult Check()
        {
            DateTime end;

            nextUpdate = DateTime.Now;
            nextUpdate = nextUpdate.AddMilliseconds(1000 - nextUpdate.Millisecond);

            if (timeout.Value == TimeSpan.MaxValue)
                end = DateTime.MaxValue;
            else
                end = DateTime.Now + timeout.Value;

            while (true)
            {
                DateTime now = DateTime.Now;

                if (now < nextUpdate)
                {
                    Thread.Sleep(500);
                    continue;
                }
                if (now > end)
                    return NodeResult.Skip;

                if (year.Value.Check(nextUpdate.Year) && month.Value.Check(nextUpdate.Month) && day.Value.Check(nextUpdate.Day) && hour.Value.Check(nextUpdate.Hour) && minute.Value.Check(nextUpdate.Minute) && second.Value.Check(nextUpdate.Second))
                    return NodeResult.Success;

                nextUpdate = nextUpdate.AddSeconds(1);
            }
        }
开发者ID:jbatonnet,项目名称:flowtomator,代码行数:30,代码来源:TimedEvent.cs

示例14: FromUnixTimeStamp

        private static DateTime FromUnixTimeStamp(ulong unixTimeStamp)
        {
            DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();

            return dtDateTime;
        }
开发者ID:Sleeckx,项目名称:Jamie,代码行数:7,代码来源:Picasa.cs

示例15: ExtractDate

   private static DateTime ExtractDate( string input, string pattern, CultureInfo culture )
   {
      DateTime dt = DateTime.MinValue;
      var regex = new Regex( pattern );
      if ( regex.IsMatch( input ) )
      {
         var matches = regex.Matches( input );
         var match = matches[0];
         var ms = Convert.ToInt64( match.Groups[1].Value );
         var epoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc );
         dt = epoch.AddMilliseconds( ms );

         // adjust if time zone modifier present
         if ( match.Groups.Count > 2 && !String.IsNullOrEmpty( match.Groups[3].Value ) )
         {
            var mod = DateTime.ParseExact( match.Groups[3].Value, "HHmm", culture );
            if ( match.Groups[2].Value == "+" )
            {
               dt = dt.Add( mod.TimeOfDay );
            }
            else
            {
               dt = dt.Subtract( mod.TimeOfDay );
            }
         }

      }
      return dt;
   }
开发者ID:BLesnau,项目名称:PixelPrinter,代码行数:29,代码来源:StringExtensions.cs


注:本文中的System.DateTime.AddMilliseconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。