countdown - A Lasso type that stores the number of days, hours, minutes, and seconds remaining from now until a date in the future
The project countdown and its source files are hosted on GitHub.
[countdown] is a Lasso type that stores the number of days, hours, minutes, and seconds remaining from now until a date in the future (t0). It is useful for a countdown situation, like on New Year's Eve or when launching vehicles into space.
countdown accepts three parameters.
-t0 is required and must be a date type. Its value is the time to which we will count down.
-tztarget is optional but must be a string type. Its value is the time zone in which the count down will occur.
-tzserver is optional but must be a string type. Its value is the server's time zone.
countdown has the following methods.
->days returns the number of days remaining.
->hours returns the number of hours remaining.
->minutes returns the number of minutes remaining.
->seconds returns the number of seconds remaining.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ local( 't0' = '2015-01-01 00:00:00', 'tztarget' = 'America/New_York', 'tzserver' = 'America/Los_Angeles'); local('c') = countdown(-t0=#t0, -tztarget=#tztarget, -tzserver=#tzserver); ] <h3>Current time in T-0's time zone</h3> <p>[tz_convert(-dt=date, -tzin=#tzserver, -tzout=#tztarget)]</p> <h3>Countdown to T-0, time remaining</h3> <p>Days: [#c->days]</p> <p>Hours: [#c->hours]</p> <p>Minutes: [#c->minutes]</p> <p>Seconds: [#c->seconds]</p>
1 2 3 4 5 6 7
<h3>Current time in T-0's time zone</h3> <p>2014-12-28 08:52:37</p> <h3>Countdown to T-0, time remaining</h3> <p>Days: 3</p> <p>Hours: 15</p> <p>Minutes: 7</p> <p>Seconds: 23</p>
Installation and Requirements¶
[countdown] requires [tz_convert] in order to convert countdowns between time zones. For more information on [tz_convert], read the article tz_convert - Convert datetime types between time zones in Lasso 8.
The repository contains the tag [countdown] in a file named countdown.lasso.
For [countdown], install and configure the following requirements and their requirements as well.
- Place the file countdown.lasso in the appropriate location on your server, and restart the appropriate scope of Lasso if needed.
The repository also contains a directory countdown_demo containing the demo. In this directory there is a web page named index.lasso. The demo includes a jQuery plugin and jQuery itself. Copy the directory countdown_demo to your web server.
The demo uses [tz_select] in order to render an HTML select menu of time zones, but is not required by [countdown]. For more information on [tz_select], read the article tz_select - Display an HTML select menu of time zones with Lasso.
For the demo, install and configure the additional requirements.
Did you like this article? Please send me a Gratipay, as little as 25¢ per week!
Updates, suggestions and comments regarding this article may be sent to Steve Piercy, firstname.lastname@example.org or comment using Disqus.