Imports System.Runtime.CompilerServices

Public Module DateTimeEx
    Const UnixEraStartTicks As Long = 621355968000000000
    <Extension> Public Function UnixTimestamp(value As Date) As Long
        Dim UnixEraTicks = value.Ticks - UnixEraStartTicks
        Return UnixEraTicks \ 10000
    End Function
    Public Function DateFromUnix(timestamp As Long) As Date
        Return New Date(UnixEraStartTicks + timestamp * 10000)
    End Function
End Module
