SD Relative Timer control

Official Content
This documentation is valid for:

This article describes how to configure a control on the screen to count down to an event that will take place in the future or to express the time elapsed after the start of an event. For example, suppose it is 3 p.m. and an event is programmed for 4 p.m. You need to add a countdown that shows the number of minutes left for the event to begin. Also, if the event is currently taking place, you may want to show, for example, the time elapsed since the beginning of the event.

You can achieve this by defining an attribute or variable based on the DateTime data type and setting its Control Type property = SD Relative Timer.

You must assign a DateTime value to the attribute/variable, with which the control is initialized when the count is started. 

Properties

Format Style with which the time interval will be displayed.
Units Time units used to display the time interval.
Most Representative Unit Only Indicates whether only the most significant unit of time should be displayed (truncating).
Counting Type Sets if the SD Relative Timer control will make a countdown, count the elapsed time, or both.
Prefix Text Text that precedes the relative time.
Suffix Text Text to be displayed after the relative time.
Maximum Seconds Sets a number of seconds such that when the counter becomes equal to or greater than it, the text set in the Maximum Text property is shown.
Maximum Text
Text to display after the elapse of the interval in seconds set in the Maximum Seconds property, since the start time.
Minimum Seconds Sets a number of seconds such that when the counter becomes equal to or lower than it, the text set in the Minimum Text property is shown.
Minimum Text Text to display after the elapse of the interval in seconds set in the Minimum Seconds property.

Themes

It applies to properties of the Attribute theme class.

Events

TimerStatusChanged

This event is triggered when any of the following conditions are met:

  • When the control starts to be executed.
  • Relative time elapsed; that is to say, when the target time is reached, this event will be executed. 
  • The Maximum Seconds value has been reached.
  • The Minimum Seconds value has been reached.

Sample

Create a Panel for Smart Devices object with a variable based on the DateTime data type. Set the variable Control Type property = SD Relative Timer.

Program the Panel Start event as shown below:

Event Start
    &SDRelativeTimer    = Now()
    &SDRelativeTimer    = &SDRelativeTimer.AddMinutes(15) 
EndEvent

When executing the application, you will see the following:

SDRelativeTimerSam_gif

Suppose that once the countdown reaches zero, a text must appear indicating that the event is currently taking place. To achieve this, you have to use the TimerStatusChanged event associated with the control.

Add the third line of code to the Start event, as shown below:

Event Start
    &SDRelativeTimer = Now()
    &SDRelativeTimer = &SDRelativeTimer.AddMinutes(15)
    &TimerStarted    = False
EndEvent

Program the TimerStatusChanged event associated with the control as shown below:

Event &SDRelativeTimer.TimerStatusChanged
    Composite
        If &TimerStarted = False
          //The control start to be executed
            &TimerStarted = True
        Else
            &SDRelativeTimer.PrefixText = 'Live Now'
        EndIf
    EndComposite
EndEvent    

TimerStatusChanged event explanation

This event is executed and &TimerStarted = False. So, you enter the if statement, the counter starts counting, and the value of &TimerStarted is changed to True. When the counter reaches zero, the event will be triggered again, this time entering the else statement. So, the text 'Live Now' is assigned to the control's Prefix Text property.

When executing the application, you will see the following:

SDRelativeTimerSam1_gif

Availability

Available as from GeneXus 16 upgrade 3 for iOS.

Available as from GeneXus 16 upgrade 8 for Android.

Scope

Platforms  Smart Devices (iOS)