Skip to content

Time tracker for Android using 0-1000 time units mapped to 24 hours

Notifications You must be signed in to change notification settings

cloudmillgames/cmg_time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmg_time

A time tracker using 0-1000 time units over 24 hours.

Developed to learn some Flutter/Dart

Planned features:

Here's a javascript function that converts realtime to ticks:

  // Returns the ISO week of the date.
  Date.prototype.getWeek = function () {
    var date = new Date(this.getTime());
    date.setHours(0, 0, 0, 0);
    // Thursday in current week decides the year.
    date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
    // January 4 is always in week 1.
    var week1 = new Date(date.getFullYear(), 0, 4);
    // Adjust to Thursday in week 1 and count number of weeks from date to week1.
    return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
      - 3 + (week1.getDay() + 6) % 7) / 7);
  }

  function currentTime() {
    // CMG-TIME: based on 100rabbits alternative time system
    var date = new Date();
    var hour = date.getHours();
    var min = date.getMinutes();
    var sec = date.getSeconds();

    var allseconds = 24 * 60 * 60;
    var curseconds = (hour * 3600) + (min * 60) + sec;
    var secsbetweenticks = allseconds / 1000;
    var cursubticks = Math.floor(((curseconds % secsbetweenticks) / secsbetweenticks) * 1000);
    var cmgticks = Math.floor((curseconds / allseconds) * 1000);

    var weekofyear = date.getWeek();
    var cmgdate = String.fromCharCode(Math.floor(weekofyear / 2) + 64) + Math.floor(weekofyear % 14).toString()

    var presentation = cmgticks.toString() + "-" + cmgdate;

    document.getElementById("cmg-time").innerText = presentation;
    document.getElementById("cmg-subticks").innerText = cursubticks;
    var t = setTimeout(function () { currentTime() }, 1000);
  }

  function updateTime(k) {
    if (k < 10) {
      return "0" + k;
    }
    else {
      return k;
    }
  }

  currentTime();