-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqlockthree.js
68 lines (61 loc) · 1.65 KB
/
qlockthree.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var _ = require('lodash');
var displayCharsMinutes = "moinsoledixetrquartpmdvingt-cinquetsdemiepam";
var displayCharsHours = "ilnestodeuxquatretroisneufunesepthuitsixcinqmidixminuitonzerheures";
console.log(_.chunk(displayCharsHours, 11));
var now = new Date();
var getTextHours = function(date) {
var hoursIntToText = {
0:'minuit',
1:'une',
2:'deux',
3:'trois',
4:'quatre',
5:'cinq',
6:'six',
7:'sept',
8:'huit',
9:'neuf',
10:'dix',
11:'onze',
12:'midi',
13:'une',
14:'deux',
15:'trois',
16:'quatre',
17:'cinq',
18:'six',
19:'sept',
20:'huit',
21:'neuf',
22:'dix',
23:'onze'
};
return hoursIntToText[date.getHours()];
}
var getTextMinutes = function(date) {
var minutes = date.getMinutes();
if(_.inRange(minutes, 5, 9)) {
return "cinq";
} else if(_.inRange(minutes, 10, 14)) {
return "dix";
} else if(_.inRange(minutes, 15, 19)) {
return "et quart";
} else if(_.inRange(minutes, 20, 24)) {
return "vingt";
} else if(_.inRange(minutes, 25, 29)) {
return "vingt-cinq";
} else if(_.inRange(minutes, 30, 34)) {
return "et demie";
} else if(_.inRange(minutes, 35, 39)) {
return "moins vingt-cinq";
} else if(_.inRange(minutes, 40, 44)) {
return "moins vingt";
} else if(_.inRange(minutes, 45, 49)) {
return "moins le quart";
} else if(_.inRange(minutes, 50, 54)) {
return "moins dix";
} else if(_.inRange(minutes, 55, 59)) {
return "moins cinq";
}
};
console.log("il est " + getTextHours(now) + " heures " + getTextMinutes(now));