Streak counter widget with reset option

Former Member
Former Member
I'm trying to create a simple streak widget, that would simply show a number of days between two moments: the first one being a set date and the second - present day with the ability to reset streak with a push of a button.
I got to the point of showing streak on screen, but I'm struggling with the resetting part.

the error I'm getting:
Could not find symbol substract.

Symbol Not Found Error

in ustawdate (/Users/swity/eclipse-workspace/bulla/./source/streakView.mc:11)

in onKey (/Users/swity/eclipse-workspace/bulla/./source/streakView.mc:21)

in handleEvent (/private/var/jenkins/workspace/Tech-Rel-CIQ-Mac/mbsimulator/submodules/technology/monkeybrains/virtual-machine/api/WatchUi.mb:618)


Here is the code:

using Toybox.WatchUi as Ui;
using Toybox.Time;
using Toybox.Time.Gregorian;

function reset() {
streak.substract(streak);
Ui.requestUpdate();
}

class streakDelegate extends Ui.InputDelegate {

function initialize() {
InputDelegate.initialize();
}

function onKey(keyEvent) {
reset();
}
}

class streakView extends Ui.View {

var moment1 = new Time.Moment(1524268800);
var moment2 = new Time.Moment(Time.today().value());
var streak = moment2.subtract(moment1);
var czas = (okres.value() / 86400).toString();

function initialize() {
View.initialize();
}

function onLayout(dc) {
setLayout(Rez.Layouts.MainLayout(dc));
}

function onShow() {
}

function onUpdate(dc) {
var view = View.findDrawableById("tekst");
view.setText(streak);
View.onUpdate(dc);
}

function onHide() {
}
}