TwelvestoneFlash

time display question as2


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
arigato
 
2010-01-21

For a clock widget, displaying Eastern Standard Time: onClipEvent (enterFrame) { myTime2 = new Date(); nSeconds2 = myTime2.getSeconds(); nMinutes2 = myTime2.getMinutes(); nHours2 = myTime2.getUTCHours()-5;

if (nHours2<=0) {
    nHours2 = 24+nHours2;
}

if (length(nMinutes2) == 1) {
    nMinutes2 = "0"+nMinutes2;
}

nTime2 = nHours2+":"+nMinutes2;

}

Works swell, except that 10 minutes after midnight displays as 24:10 - how would I get it to display 00:10 ?

persist
 
2010-01-21

onClipEvent (enterFrame) { myTime2 = new Date(); nSeconds2 = myTime2.getSeconds(); nMinutes2 = myTime2.getMinutes(); nHours2 = myTime2.getUTCHours()-5;

if (nHours2<=0) {
    nHours2 = 24+nHours2;
            if(nHours2==24){
                nHours2 = "00";
            }
}

if (length(nMinutes2) == 1) {
    nMinutes2 = "0"+nMinutes2;
}

nTime2 = nHours2+":"+nMinutes2;

}

This is some ugly code, but my brain is n't working today to figre out a simple one liner that does everything at once. this should work.

I noticed you're looking for the double digit. you may also want to prepend a zero on your single integers. ?

arigato
 
2010-01-21

At this point, functional is more important than pretty - seems to work. Cheers!

I had come up with pretty much the same but forgot an "=". Oops!

JLM
 
2010-01-28

you can probably take time off the date and substring the toString but that would be rather ugly hacky one liner that since you have a solution is prob not worth working out.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

time display question as2