Last active
September 25, 2020 20:12
-
-
Save danieldietrich/8fa7fd56538ccbefdf2735f400800aad to your computer and use it in GitHub Desktop.
Emoji numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function numji(i, c = 0) { | |
let s = ""; | |
if (!Number.isNaN(i) && Number.isFinite(i)) { | |
i = Math.abs(Math.trunc(i)); | |
do { | |
c--; | |
s = String.fromCharCode(0x0030 + i % 10, 0xFE0F, 0x20E3) + s; | |
i = Math.trunc(i / 10); | |
} while (i > 0 || c > 0); | |
} | |
return s; | |
} |
Example:
// DD.MM.YYYY
function dateji(d = new Date()) {
return `${numji(d.getDate(), 2)}.${numji(d.getMonth() + 1, 2)}.${numji(d.getFullYear())}`;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: the number of digits
c
will never change the sign.-Number.MAX_VALUE - 1
is equal to-Number.MAX_VALUE
Number.MIN_SAFE_INTEGER * Number.MAX_VALUE
is equal to-Infinity