@CharlieRoot/

FuchsiaDirectThing

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var now = new Date();
var Gengou = now.toLocaleDateString("ja-JP-u-ca-japanese", { era: "long", year:"numeric" })
    .replace(/(^|[^\d])1(?=$|[^\d])/, '$1元').replace(/\u200e/g, "").replace(" ", "");

// 'GENGOU元年', 'GENGOU99年' から '元年', '99年' を抜き取る
var Gengou2 = Gengou.match(/元年|\d+年/)[0];

if (Gengou2 == "元年" || Gengou2.match(/[2-9]年/)){
  var retval = Gengou + ': red';
} else if (Gengou2.match(/[1-9][0-9]年/)) {
  var retval = Gengou + ': green';
} else {
  var retval = Gengou + ': blue';
}

retval
Native Browser JavaScript