Have you considered working with Milliseconds for your math?
Also, your blocks image shows a lack of procedure parameters and return values from procedures.
https://code.appinventor.mit.edu/reference/components/sensors.html#Clock
Clock
Non-visible component that provides the instant in time using the internal clock on the phone. It can fire a timer at regularly set intervals and perform time calculations, manipulations, and conversions.
Operations on dates and times, such as from DatePicker
and TimePicker
, are accomplished through methods in Clock. Date and Time are represented as InstantInTime and Duration.
Instants are assumed to be in the device’s local time zone. When they are converted to or from milliseconds, the milliseconds for a given Instance are calculated from January 1, 1970 in UTC (Greenwich Mean Time).
Methods to convert an Instant to text are also available. Acceptable patterns are empty string, MM/dd/YYYY HH:mm:ss a
, or MMM d, yyyy HH:mm
. The empty string will provide the default format, which is "MMM d, yyyy HH:mm:ss a"
for FormatDateTime
, "MMM d, yyyy"
for FormatDate
. To see all possible formats, please see here.
A note on combining date and time: In order to combine the date from one Instant and the time from another, for example from a DatePicker
and TimePicker
, extract the parts as text and use the text to create a new Instant. For example:
Properties
TimerAlwaysFires
Will fire even when application is not showing on the screen if true
TimerEnabled
Specifies whether the Timer
event should run.
TimerInterval
Specifies the interval between subsequent Timer
events.
Note: Drift may occur over time and that the system may not honor the timing specified here if the app or another process on the phone is busy.
Events
Timer()
The Timer event runs when the timer has gone off.
Methods
AddDays(instant,quantity)
Returns an instant in time some days after the given instant.
AddDuration(instant,quantity)
Returns an instant in time some duration after the argument
AddHours(instant,quantity)
Returns an instant in time some hours after the given instant.
AddMinutes(instant,quantity)
Returns an instant in time some minutes after the given instant.
AddMonths(instant,quantity)
Returns an instant in time some months after the given instant.
AddSeconds(instant,quantity)
Returns an instant in time some seconds after the given instant.
AddWeeks(instant,quantity)
Returns An instant in time some weeks after the given instant.
AddYears(instant,quantity)
Returns an instant in time some years after the given instant.
DayOfMonth(instant)
Returns the day of the month.
Duration(start,end)
Returns the milliseconds by which end follows start (+ or -)
DurationToDays(duration)
Returns the duration converted from milliseconds to days.
DurationToHours(duration)
Returns the duration converted from milliseconds to hours.
DurationToMinutes(duration)
Returns the duration converted from milliseconds to minutes.
DurationToSeconds(duration)
Returns the duration converted from milliseconds to seconds.
DurationToWeeks(duration)
Returns the duration converted from milliseconds to weeks.
FormatDate(instant,pattern)
Converts and formats an instant into a string of date with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
FormatDateTime(instant,pattern)
Converts and formats an instant into a string of date and time with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
FormatTime(instant)
Converts and formats the given instant into a string with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
GetMillis(instant)
Returns the instant in time measured as milliseconds since 1970.
Hour(instant)
Returns the hours for the given date.
MakeDate(year,month,day)
Returns an instant in time specified by year, month, date in UTC. Valid values for the month field are 1-12 and 1-31 for the day field.
MakeInstant(from)
Returns an instant in time specified by MM/dd/YYYY hh:mm:ss or MM/dd/YYYY or hh:mm.
MakeInstantFromMillis(millis)
Returns an instant in time specified by the milliseconds since 1970 in UTC.
MakeInstantFromParts(year,month,day,hour,minute,second)
Returns an instant in time specified by year, month, date, hour, minute, second in UTC.
MakeTime(hour,minute,second)
Returns an instant in time specified by hour, minute, second in UTC.
Minute(instant)
Returns the minutes for the given date.
Month(instant)
Returns the number of the month for the given instant.
MonthName(instant)
Returns the name of the month for the given instant.
Now()
Returns the current instant in time read from phone’s clock.
Second(instant)
Returns the seconds for the given instant.
SystemTime()
Returns the phone’s internal time.
Weekday(instant)
Returns the weekday for the given instant.
WeekdayName(instant)
Returns the name of the weekday for the given instant.
Year(instant)
Returns the year of the given instant.