/ Published in: ASP
URL: http://reusablecode.blogspot.com/2009/02/difference-between-two-stardates.html
Calculates the difference between two Stardates and returns the result as a human-readable string.
Expand |
Embed | Plain Text
<% ' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA. ' Calculate the difference between two stardates. function stardatediff(firstStardate, secondStardate) dim years dim years1 dim years2 dim days dim days1 dim days2 dim hours dim hours1 dim hours2 years1 = mid(firstStardate, 0, 2) years2 = mid(secondStardate, 0, 2) days1 = mid(firstStardate, 2, 3) days2 = mid(secondStardate, 2, 3) hours1 = mid(firstStardate, 6, 1) hours2 = mid(secondStardate, 6, 1) if years1 > years2 then years = years1 - years2 else years = years2 - years1 end if if days1 > days2 then days = (days1 * 366 / 1000) - (days2 * 366 / 1000) else days = (days2 * 366 / 1000) - (days1 * 366 / 1000) end if if hours1 > hours2 then hours = (hours1 * 144 / 60) - (hours2 * 144 / 60) else hours = (hours2 * 144 / 60) - (hours1 * 144 / 60) end if days = round(days) hours = round(hours, 1) stardatediff = "There are $years years, $days days, and $hours hours between Stardate $firstStardate and Stardate $secondStardate." end function %>
You need to login to post a comment.
