Skip to content

Instantly share code, notes, and snippets.

@heim
Created October 10, 2012 10:56
Show Gist options
  • Save heim/3864762 to your computer and use it in GitHub Desktop.
Save heim/3864762 to your computer and use it in GitHub Desktop.
define(["moment"], function(moment) {
function PrognosisTimeKeeper(prognosisTime) {
var initialPrognosisTime = function() {
//this == Window
var currentTime = moment(this.lastPrognosisTime, "DD.MM.YYYY HH:MM");
return currentTime.add("h", 4).format("YYYY-MM-DD HH\\0\\0");
};
var setNewPrognosisTime = function() {
this.lastPrognosisTime = prognosisTime.get("lastPrognosisProductionTime");
};
var updatePrognosisTime = function() {
prognosisTime.fetch();
};
//this == PrognosisTimeKeeper
this.lastPrognosisTime = prognosisTime.get("lastPrognosisProductionTime");
this.selectedPrognosisTime = initialPrognosisTime();
prognosisTime.on("change", setNewPrognosisTime, this);
setInterval(updatePrognosisTime, 60000);
};
return ( PrognosisTimeKeeper );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment