@CharlieRoot/

SilkyDirtyQuadrant

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年' を抜き取る
Gengou = Gengou.match(/元年|\d+年/)[0];

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

retval
Native Browser JavaScript