Imports BetterSeal
Public Class Time
Public Shared Function epochTimeStamp(ByVal Optional year As Integer = 1970,
Optional month As Integer = 1,
Optional day As Integer = 1) As Integer
Dim currentTime As DateTime = DateTime.Now.ToUniversalTime
Dim epoch As New DateTime(year, month, day)
Return (currentTime.Subtract(epoch)).TotalSeconds
End Function
Public Shared Function GetDaySuffix(day As Integer) As String
Select Case day
Case 1, 21, 31
Return "st"
Case 2, 22
Return "nd"
Case 3, 23
Return "rd"
Case Else
Return "th"
End Select
End Function
Public Shared Function expireDate(userInfo As LoginResponse) As String
If userInfo.lifetime Then Return "Never"
Dim userEpoch As Integer = userInfo.remain
Dim secondsLeft As Integer = userEpoch - epochTimeStamp()
Dim expiredDateTime = Now.ToUniversalTime.AddSeconds(secondsLeft)
Return expiredDateTime.ToString("MMMM d") + GetDaySuffix(expiredDateTime.Day) + ", " + expiredDateTime.ToString("yyyy")
End Function
End Class
Comments