forked from akkadotnet/akka.net
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDateTimeExtensions.cs
More file actions
27 lines (24 loc) · 963 Bytes
/
Copy pathDateTimeExtensions.cs
File metadata and controls
27 lines (24 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//-----------------------------------------------------------------------
// <copyright file="DateTimeExtensions.cs" company="Akka.NET Project">
// Copyright (C) 2009-2021 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2021 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
using System;
namespace Akka.Util.Extensions
{
/// <summary>
/// DateTimeExtensions
/// </summary>
public static class DateTimeExtensions
{
private static readonly DateTime UnixOffset = new DateTime(1970, 1, 1);
/// <summary>
/// Converts given date and time to UNIX Timestamp - number of milliseconds elapsed since 1 Jan 1970
/// </summary>
public static long ToTimestamp(this DateTime dateTime)
{
return (long)(dateTime - UnixOffset).TotalMilliseconds;
}
}
}