Countdown Extension for Thunkable and App Inventor



Today I am releasing my very first extension for Thunkable and App Inventor, the countdown extension. This extension provides a range of functions to get the duration between two specified dates, a startDate, and an endDate.

The first two "GetCountdown" methods return a list including the days, hours, minutes, and seconds remaining between two dates.

GetCountdownFromInstants

Returns a list with the days, hours, minutes, and seconds between two dates. Arguments must be instants. This function ties in well if you have a Clock component in your project.

Returns YailList [days, hours, minutes, seconds]



GetCountdownFromStrings

Returns a list with the days, hours, minutes, and seconds between two dates. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns YailList [days, hours, minutes, seconds]

GetDurationInYears

Returns the number of years between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm. Return value is processed through Math.floor to retrieve the nearest whole number to return.

Returns long (duration)

GetDurationInMonths

Returns the number of months between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm. Return value is processed through Math.floor to retrieve the nearest whole number to return.

Returns long (duration)

GetDurationInWeeks

Returns the number of weeks between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns long (duration)

GetDurationInDays

Returns the number of days between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns long (duration)

GetDurationInHours

Returns the number of hours between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns long (duration)

GetDurationInMinutes

Returns the number of minutes between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns long (duration)

GetDurationInSeconds

Returns the number of seconds between given start date and end date. Arguments must be formatted correctly like MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm.

Returns long (duration)


GetCurrentTimeAsString

Returns a String representing the current date and time in the format MM/DD/YYYY hh:mm:ss.

Returns String (Date/time)


Example 1

In this example, I am creating a countdown to Google I/O 2020 which is updated every second by a clock component.

In the example file I have included the output of all of the methods in this extension which look like this:



You can download the example project file here: CountdownExtensionText.aia


Example 2 - Version 2 Features

Version 2 of the countdown extension adds a number of useful features including a timer as well as functions to compare different times.

In the blocks above you can see demonstrated the timer feature, on button 2 click, the start timer block is executed to start the timer with a specified duration in milliseconds. You can also set the interval that the timer counts down, typically this would be one second but you can customise it to your needs.

The blocks above demonstrate another new feature, IsDateAfter, this method returns true if date one is after date two. This provides a way to compare different dates together, there is also methods for IsDateBefore, and IsDateEqual.

You can download the example project file here: CountdownExample2.aia

Download extension here:



Download version 1 countdown.aix


Version History

Version 2

-Added timer 
-Added IsDateAfter
-Added IsDateBefore
-Added IsDateEqual

Version 1

-Improved documentation
-Added refinements

Version 0

-Added everything!




Icons made by Egor Rumyantsev from www.flaticon.com is licensed by CC 3.0 BY

Was this helpful?

Yes No

Comments

  1. Can it run timer in background ???

    ReplyDelete
    Replies
    1. Hi Roy,

      Yes the timer block runs in the background and triggers the OnTick and OnFinish events.

      Delete
  2. could you add millisfromStart to the tick event ?

    ReplyDelete
  3. How i can use dd\MM\yyyy format?

    ReplyDelete

Post a Comment

Thunkable Components