Posted By

Scooter on 02/01/09


Tagged

fun Star Trek


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wizard04


Stardate


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com/2009/01/stardate.html

Calculate the stardate in the 24th century Star Trek universe for a given Gregorian date in the real universe. Requires my str_pad() function.

  1. <%
  2. ' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Returns the stardate for a given date.
  10. ' Requires str_pad()
  11. function stardate(someDateTime)
  12. dim season
  13. dim episode
  14. dim fractime
  15.  
  16. season = cStr(Year(someDateTime) - 1947)
  17. episode = str_pad(Round(1000 / 366 * DatePart("y", someDateTime), 0), 3, "0", "left")
  18. fractime = left(cStr((Hour(someDateTime) * 60 + Minute(someDateTime)) / 144), 1)
  19.  
  20. stardate = season & episode & "." & fractime
  21. end function
  22. %>

Report this snippet  

You need to login to post a comment.