Posted By

Scooter on 11/29/08


Tagged

DateTime


Versions (?)

Swatch Internet Time


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com/2008/11/swatch-internet-time.html

Convert a time value into a Swatch beat. Requires my str_pad() and floor() functions. To return an accurate result, the time value passed in needs to be UTC/GMT (in other words, without offset). There are two ways to achieve this: set your server's time zone to GMT, or use my UTC time function.

  1. <%
  2. ' Copyright (c) 2008, 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 Swatch Internet Time beats for the given time value.
  10. ' To be accurate, the input value MUST be Universal Coordinated Time (UTC).
  11. ' REQUIRES: str_pad(), floor()
  12. function swatch(someTime)
  13. swatch = str_pad(floor(((Hour(someTime) * 3600 * 1000) + (Minute(someTime) * 60 * 1000) + (Second(someTime) * 1000)) / 86400), 3, "0", STR_PAD_LEFT)
  14. end function
  15. %>

Report this snippet  

You need to login to post a comment.