startMetricClock()
This starts an interval that calculates the metric time as much as possible. Each cycle it sets out an event that holds the new metric time.
document.addEventListener('timeupdate', (e)=>{
let time = e.detail
let timeDis = document.querySelector('.currentClock')
timeDis.textContent = time.HC+ time.DC+ time.C+'c'
})
This code accesses the event and then extracts the current time in chron. It gets the full time string from the clock and then takes the first 3 digits which is always Hc Dc c.
{
HC:microCStr[0],
DC:microCStr[1],
C:microCStr[2],
dC:microCStr[3],
cC:microCStr[4],
mC:microCStr[5],
miC:microCStr[6],
miCFull: microCStr
}
This is what the detail object looks like. All values are stored as strings and all the digits that are in MiCFull are already parsed into individual strings. In addition, it returns the full metric time as a string in miC. miC can be represented as C/10,000. The startMetricClock() function has no properties to be input, and to run it simply use:
startMetricClock()
stopMetricClock()
This ends the interval of startMetricClock(). It has no properties and can be started again with the aforementioned startMetricClock() function. To use it, call:
stopMetricClock()
convertToMetric()
This function takes in a time from the old system and converts them to metric. It automatically fills in a 0 for any values that are not provided, and assumes 24 hour time.
{
KC:microCStr[index-8] ?? '0',
HC:microCStr[index-7] ?? '0',
DC:microCStr[index-6] ?? '0',
C:microCStr[index-5] ?? '0',
dC:microCStr[index-4] ?? '0',
cC:microCStr[index-3] ?? '0',
mC:microCStr[index-2] ?? '0',
mic:microCStr[index-1] ?? '0',
miCFull: microCStr
}
It returns a string that can run up to a KC and automatically puts in a 0 for any missing units. In addition, it returns the full metric time as a string in miC. miC can be represented as C/10,000.
let metricTime = convertToMetric(hours, minutes, seconds, millisec) //all values are optional
This takes a metric time number that is in C and converts it into old time.
{
hours:String(hours).padStart(2,'0'),
minutes: String(min).padStart(2,'0'),
seconds: String(sec).padStart(2,'0'),
millisec: String(millisecl).padStart(2,'0'),
fullTime: millisec
}
It returns an hour, minute, seconds, and millisec time as well as the full time in just milliseconds. When calling it use:
let oldTime = convertToOld(chron)
getCurrentMetricTime()
This function grabs the current metric time and returns it as:
{
HC:microCStr[0],
DC:microCStr[1],
C:microCStr[2],
dC:microCStr[3],
cC:microCStr[4],
mC:microCStr[5],
miC:microCStr[6],
miCFull: microCStr
}
This is the same as in the metric clock functions. It has a string for each digit as well as a string for the whole time in miC. To run it use:
let currentTime = getCurrentMetricTime()