CLI 世界时钟 - 工作专用

由于工作性质原因,需要了解世界各地同事的..作息时间(主要是工作时间),便于工作交接还有一些重要工作的Check Point,SLA Tracking等等。所以简单的世界时钟很难满足我的需求。所以,自己制作了这个小工具。

  • “-“ 休息时间
  • “=” 工作
  • “*” 现在时间
World Working Timebar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var moment = require('moment')
var entities =[
{
city: 'HK',
tzoffset: 8,
timebar: ['-','-','-','-','-','-','-','-','-','=','=','=','=','|','=','=','=','=','=','-','-','-','-','-','-']
},
{
city: 'IN',
tzoffset: 5.5,
timebar: ['-','-','-','-','-','-','-','-','-','=','=','=','=','|','=','=','=','=','=','-','-','-','-','-','-']
},
{
city: 'LN',
tzoffset: 0,
timebar: ['-','-','-','-','-','-','-','-','-','=','=','=','=','|','=','=','=','=','=','-','-','-','-','-','-']
},
{
city: 'NY',
tzoffset: -5,
timebar: ['-','-','-','-','-','-','-','-','-','=','=','=','=','|','=','=','=','=','=','-','-','-','-','-','-']
},
]
for (var i = 0; i < entities.length; i++) {
nowHour = moment().utcOffset(entities[i]['tzoffset']).hour()
nowTime = moment().utcOffset(entities[i]['tzoffset']).format('HH:mm')
if (moment().utcOffset(entities[i]['tzoffset']).hour() < 13) {
entities[i]['timebar'][nowHour] = '*'
} else {
entities[i]['timebar'][nowHour + 1] = '*'
}
console.log(entities[i]['city'] + ' (' + nowTime + ') [' + entities[i]['timebar'].join('') + ']')
}