Re: Time Remaining?

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 17456
interpreted = N
texte = (Brian B. Burton) >Is it possible using a math context to calculate >Days:hours:minutes:seconds remaining until some deadline? >... >I figure I'd somehow have to convert the two dates to seconds... Yes, you can use [math] for that. I am working on a method for user tracking right now and have done something similar. Maybe it is not the easiest, most elegant way, but I could adapt it to your needs and it works...It counts up and down and recognizes an exact match (this can really happen, I know it ;-) You have just to insert date and time of your target in the very first line of code and customize the output section. Be careful with date and time since WebCat takes any value and does not look for wrong input. To test the behavior when a user hits right on the spot, insert [date] and [time] as your deadline within the curly {brackets}.-------------------------------------------------- [math show=f]Deadline={12/31/1998}*24*60*60+{12:00:00}[/math] [math show=f]Current={[date]}*24*60*60+{[time]}[/math][showif [math]Deadline-Current[/math]<0] [math show=f]Difference=Current-Deadline[/math] [math show=f]Hit=-1[/math] [/showif] [showif [math]Deadline-Current[/math]=0] [math show=f]Difference=0[/math] [math show=f]Hit=0[/math] [/showif] [showif [math]Deadline-Current[/math]>0] [math show=f]Difference=Deadline-Current[/math] [math show=f]Hit=1[/math] [/showif][math show=f]D=floor(Difference/60/60/24)[/math] [math show=f]H=floor(Difference/60/60-D*24)[/math] [math show=f]M=floor(Difference/60-D*24*60-H*60)[/math] [math show=f]S=floor(Difference-D*24*60*60-H*60*60-M*60)[/math] [showif [math]Hit[/math]=0] Congratulations - you got it! [/showif] [hideif [math]Hit[/math]=0] [showif [math]Hit[/math]=1]You have still [/showif] [showif [math]Hit[/math]=-1]Sorry, you are [/showif] [math]D[/math] days, [math]H[/math] hours, [math]M[/math] minutes and [math]S[/math] seconds [showif [math]Hit[/math]=1] to catch me![/showif] [showif [math]Hit[/math]=-1] too late...[/showif] [/hideif] --------------------------------------------------Peter__________________________________________ Peter Ostry - po@ostry.com - www.ostry.com Ostry & Partner - Ostry Internet Solutions Auhofstrasse 29 A-1130 Vienna Austria fon ++43-1-8777454 fax ++43-1-8777454-21 Associated Messages, from the most recent to the oldest:

    
  1. Re: Time Remaining? (Peter Ostry 1998)
  2. Time Remaining? (Brian B. Burton 1998)
(Brian B. Burton) >Is it possible using a math context to calculate >Days:hours:minutes:seconds remaining until some deadline? >... >I figure I'd somehow have to convert the two dates to seconds... Yes, you can use [math] for that. I am working on a method for user tracking right now and have done something similar. Maybe it is not the easiest, most elegant way, but I could adapt it to your needs and it works...It counts up and down and recognizes an exact match (this can really happen, I know it ;-) You have just to insert date and time of your target in the very first line of code and customize the output section. Be careful with date and time since WebCat takes any value and does not look for wrong input. To test the behavior when a user hits right on the spot, insert [date] and [time] as your deadline within the curly {brackets}.-------------------------------------------------- [math show=f]Deadline={12/31/1998}*24*60*60+{12:00:00}[/math] [math show=f]Current={[date]}*24*60*60+{[time]}[/math][showif [math]Deadline-Current[/math]<0] [math show=f]Difference=Current-Deadline[/math] [math show=f]Hit=-1[/math] [/showif] [showif [math]Deadline-Current[/math]=0] [math show=f]Difference=0[/math] [math show=f]Hit=0[/math] [/showif] [showif [math]Deadline-Current[/math]>0] [math show=f]Difference=Deadline-Current[/math] [math show=f]Hit=1[/math] [/showif][math show=f]D=floor(Difference/60/60/24)[/math] [math show=f]H=floor(Difference/60/60-D*24)[/math] [math show=f]M=floor(Difference/60-D*24*60-H*60)[/math] [math show=f]S=floor(Difference-D*24*60*60-H*60*60-M*60)[/math] [showif [math]Hit[/math]=0] Congratulations - you got it! [/showif] [hideif [math]Hit[/math]=0] [showif [math]Hit[/math]=1]You have still [/showif] [showif [math]Hit[/math]=-1]Sorry, you are [/showif] [math]D[/math] days, [math]H[/math] hours, [math]M[/math] minutes and [math]S[/math] seconds [showif [math]Hit[/math]=1] to catch me![/showif] [showif [math]Hit[/math]=-1] too late...[/showif] [/hideif] --------------------------------------------------Peter__________________________________________ Peter Ostry - po@ostry.com - www.ostry.com Ostry & Partner - Ostry Internet Solutions Auhofstrasse 29 A-1130 Vienna Austria fon ++43-1-8777454 fax ++43-1-8777454-21 Peter Ostry

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

OT - SMSI complaint (2001) RE: Supressing Error Messages (1998) WebDNA5 & Tiger (2006) Unexpected error (1997) Math Problem - Format? (1997) Some Questions (1997) Bug Report, maybe (1997) nesting limits? (1998) help (2001) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Setting up WebCatalog with Retail Pro data (1996) WebDNA-Talk Digest mode broken (1997) Show shoppingcart after remove last item (1997) Variable Math (1998) Problems with SELECT MULTIPLE (1999) What is the syntax for MIME type on Apache server? (2000) [CART] (1997) ExpireDate Zero or Greater than Today (2006) no global [username] or [password] displayed ... (1997) access denied problem (1997)