Advertisement
justinooo

BetterSeal Expire Date - VB

Jun 21st, 2017
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.26 KB | None | 0 0
  1. Imports BetterSeal
  2.  
  3. Public Class Time
  4.  
  5.     Public Shared Function epochTimeStamp(ByVal Optional year As Integer = 1970,
  6.                                    Optional month As Integer = 1,
  7.                                    Optional day As Integer = 1) As Integer
  8.         Dim currentTime As DateTime = DateTime.Now.ToUniversalTime
  9.         Dim epoch As New DateTime(year, month, day)
  10.         Return (currentTime.Subtract(epoch)).TotalSeconds
  11.     End Function
  12.  
  13.     Public Shared Function GetDaySuffix(day As Integer) As String
  14.         Select Case day
  15.             Case 1, 21, 31
  16.                 Return "st"
  17.             Case 2, 22
  18.                 Return "nd"
  19.             Case 3, 23
  20.                 Return "rd"
  21.             Case Else
  22.                 Return "th"
  23.         End Select
  24.     End Function
  25.  
  26.     Public Shared Function expireDate(userInfo As LoginResponse) As String
  27.         If userInfo.lifetime Then Return "Never"
  28.         Dim userEpoch As Integer = userInfo.remain
  29.         Dim secondsLeft As Integer = userEpoch - epochTimeStamp()
  30.         Dim expiredDateTime = Now.ToUniversalTime.AddSeconds(secondsLeft)
  31.         Return expiredDateTime.ToString("MMMM d") + GetDaySuffix(expiredDateTime.Day) + ", " + expiredDateTime.ToString("yyyy")
  32.     End Function
  33.  
  34. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement