Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Import SWA (Shockwave Audio)
Import Quicktime Movies
Send to Top
Macromedia Director Workshop
Pendulum Rotate-Alphamania
Rollover Shift Hue-Alphamania
Set Screen Size
Convert Fonts
Custom Scroll Bars
Set ViewScale Property of a Flash Sprite
 

 

 

Behavior Time Difference

Added on 7/8/1999

 

Compatibilities:
D6_5 D7 D8 Mac PC Script Shockwave

This item has not yet been rated

Author: Penworks (website)

Pass 2 times with am or pm extensions. The result will be the difference in time. Use hh:mm:ss am/pm format. Reproduced with permission from Penworks Lingo User"s Journal

on timeDifference startTime, endTime
  set twelveHourAdditive =hmsToFrames("12:00:00",1,0,0)
  
  -- First account for any PM hours by adding twelve
  set startTimeAdditive =0
  if startTime contains "PM" then
    set startTimeAdditive =twelveHourAdditive
  end if
  
  set endTimeAdditive =0
  if (endTime contains "PM") then
    set endTimeAdditive =twelveHourAdditive
  end if
  
  -- Now adjust for any hours starting with 12
  if (startTime starts "12:") then
    set startTimeAdditive =startTimeAdditive - twelveHourAdditive
  end if
  
  if (endTime starts "12:") then
    set endTimeAdditive =endTimeAdditive - twelveHourAdditive
  end if
  
  -- Now remove the AM/PM stuff
  set spaceLoc =offset(" ",startTime)
  set startTime =char 1 to (spaceLoc - 1) of startTime
  set spaceLoc =offset(" ", endTime)
  set endTime =char 1 to (spaceLoc -1) of endTime
  
  -- Now convert to frames
  set startFrames =hmsToFrames(startTime, 1, 0, 0)
  set startFrames =startFrames + startTimeAdditive
  set endFrames =hmsToFrames(endTime, 1, 0, 0)
  set endFrames =endFrames + endTimeAdditive
  
  -- Now make sure we didn"t wrap around midnight
  if endFrames < startFrames then
    set endFrames =endFrames + (twelveHourAdditive * 2)
  end if
  
  -- Calculate the difference in frames, and convert back
  set difference =endFrames - startFrames
  set elapsedTime =framesToHms(difference, 1, 0, 0)
  
  return(elapsedTime)
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail