Skip to content

Commit

Permalink
Merge pull request #44 from etrusci-org/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
etrusci-org authored May 25, 2024
2 parents c54ed7e + c9faa42 commit 3d1db42
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/lib/beatsnow.js
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions app/lib/olay.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const appConf = {
'./mod/clock/clock.default.css',
],
libs: [
'./lib/beatsnow.js',
'./lib/humantimestamp.js',
'./lib/replacenumswithchars.js',
],
Expand Down
20 changes: 17 additions & 3 deletions app/mod/clock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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})

---

Expand All @@ -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

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions app/mod/clock/clock.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
3 changes: 3 additions & 0 deletions app/mod/clock/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d1db42

Please sign in to comment.