diff --git a/app/lib/beatsnow.js b/app/lib/beatsnow.js new file mode 100644 index 0000000..0c23084 --- /dev/null +++ b/app/lib/beatsnow.js @@ -0,0 +1,5 @@ +function beatsNow() +{ + const now = new Date() + return ((((now.getUTCHours() < 23 ? now.getUTCHours() + 1 : 0) * 3600) + (now.getUTCMinutes() * 60) + now.getUTCSeconds()) / 86.4).toFixed(2) +} diff --git a/app/lib/olay.js b/app/lib/olay.js index d87f0a1..a1567ce 100644 --- a/app/lib/olay.js +++ b/app/lib/olay.js @@ -17,6 +17,7 @@ const appConf = { './mod/clock/clock.default.css', ], libs: [ + './lib/beatsnow.js', './lib/humantimestamp.js', './lib/replacenumswithchars.js', ], diff --git a/app/mod/clock/README.md b/app/mod/clock/README.md index 528183c..d5cf28b 100644 --- a/app/mod/clock/README.md +++ b/app/mod/clock/README.md @@ -15,6 +15,8 @@ Display current local date and time. - [mod=clock&repnum=true&repmap=4](https://etrusci.org/tool/olay/?mod=clock&repnum=true&repmap=4) - [mod=clock&type=unix](https://etrusci.org/tool/olay/?mod=clock&type=unix) - [mod=clock&type=unixms&updaterate=80](https://etrusci.org/tool/olay/?mod=clock&type=unixms&updaterate=80) +- [mod=clock&type=beats](https://etrusci.org/tool/olay/?mod=clock&type=beats) +- [mod=clock&type=beats&beatsformat=@{beats}](https://etrusci.org/tool/olay/?mod=clock&type=beats&beatsformat=@{beats}) --- @@ -32,9 +34,10 @@ Which type of clock to load. Valid: -- `human`: Human-readable format -- `unix`: Unixtime stamp in seconds -- `unixms`: Unixtime stamp in milliseconds +- `human`: [Human-readable](https://en.wikipedia.org/wiki/Human-readable_medium_and_data) date/time format +- `unix`: [Unixtime](https://en.wikipedia.org/wiki/Unix_time) stamp in seconds +- `unixms`: [Unixtime](https://en.wikipedia.org/wiki/Unix_time) stamp in milliseconds +- `beats`: [Swatch internet time](https://en.wikipedia.org/wiki/Swatch_Internet_Time) ### humanformat @@ -54,6 +57,17 @@ Placeholders: - `{millisecond}`: Millisecond - `{timezoneOffset}`: Timezone offset (relative from UTC) +### beatsformat + +Swatch internet time format template. + +Requires: `type = beats` +Valid: `Placeholders, text, HTML` + +Placeholders: + +- `{beats}`: Beats + ### repnum Whether to replace numbers with characters. diff --git a/app/mod/clock/clock.conf.js b/app/mod/clock/clock.conf.js index cabdb72..4eb71bb 100644 --- a/app/mod/clock/clock.conf.js +++ b/app/mod/clock/clock.conf.js @@ -4,6 +4,7 @@ export const modConf = { updaterate: '1000', type: 'human', humanformat: '{year}-{month}-{day} {hour}:{minute}:{second}', + beatsformat: '@{beats} .beats', repnum: 'false', repmap: '1', } diff --git a/app/mod/clock/clock.js b/app/mod/clock/clock.js index e7287e6..ad4760b 100644 --- a/app/mod/clock/clock.js +++ b/app/mod/clock/clock.js @@ -23,6 +23,9 @@ export class Mod extends ModBase else if (this.conf.type == 'unixms') { out = String(Date.now()) } + else if (this.conf.type == 'beats') { + out = this.conf.beatsformat.replace('{beats}', beatsNow()) + } if (this.conf.repnum == 'true') { out = replaceNumsWithChars(out, this.conf.repmap)