@@ -32,49 +32,56 @@ function CustomChat.GetLanguageText( id )
32
32
return language .GetPhrase ( " custom_chat." .. id )
33
33
end
34
34
35
- local year = 60 * 60 * 24 * 365
36
- local month = 60 * 60 * 24 * 30
37
- local day = 60 * 60 * 24
38
- local hour = 60 * 60
39
- local minute = 60
40
- function CustomChat .NiceTime ( time )
41
- local L = CustomChat .GetLanguageText
35
+ do
36
+ local year = 60 * 60 * 24 * 365
37
+ local month = 60 * 60 * 24 * 30
38
+ local day = 60 * 60 * 24
39
+ local hour = 60 * 60
40
+ local minute = 60
41
+
42
+ function CustomChat .NiceTime ( time )
43
+ local L = CustomChat .GetLanguageText
44
+
45
+ local timeUnits = {
46
+ { value = Floor ( time / year ), name = " time.years" },
47
+ { value = Floor ( time / month ) % 12 , name = " time.months" },
48
+ { value = Floor ( time / day ) % 30 , name = " time.days" },
49
+ { value = Floor ( time / hour ) % 24 , name = " time.hours" },
50
+ { value = Floor ( time / minute ) % 60 , name = " time.minutes" },
51
+ { value = time % 60 , name = " time.seconds" }
52
+ }
53
+
54
+ local nonZeroUnits = {}
42
55
43
- local timeUnits = {
44
- { value = math.floor ( time / year ), name = " time.years" },
45
- { value = math.floor ( time / month ) % 12 , name = " time.months" },
46
- { value = math.floor ( time / day ) % 30 , name = " time.days" },
47
- { value = math.floor ( time / hour ) % 24 , name = " time.hours" },
48
- { value = math.floor ( time / minute ) % 60 , name = " time.minutes" },
49
- { value = time % 60 , name = " time.seconds" }
50
- }
51
-
52
- local nonZeroUnits = {}
53
- for _ , unit in ipairs ( timeUnits ) do
54
- if unit .value > 0 then
55
- table.insert ( nonZeroUnits , unit )
56
+ for _ , unit in ipairs ( timeUnits ) do
57
+ if unit .value > 0 then
58
+ table.insert ( nonZeroUnits , unit )
59
+ end
56
60
end
57
- end
58
61
59
- local selectedUnits = {}
60
- local unitsToShow = 1
61
- if time > month then
62
- unitsToShow = 2
63
- end
64
- for i = 1 , math.min ( unitsToShow , # nonZeroUnits ) do
65
- table.insert ( selectedUnits , nonZeroUnits [i ] )
66
- end
62
+ local selectedUnits = {}
63
+ local unitsToShow = 1
67
64
68
- if # selectedUnits == 0 then
69
- return " 0 " .. L ( " time.seconds " )
70
- end
65
+ if time > month then
66
+ unitsToShow = 2
67
+ end
71
68
72
- local parts = {}
73
- for _ , unit in ipairs ( selectedUnits ) do
74
- table.insert ( parts , unit .value .. " " .. L ( unit .name ) )
75
- end
69
+ for i = 1 , math.min ( unitsToShow , # nonZeroUnits ) do
70
+ table.insert ( selectedUnits , nonZeroUnits [i ] )
71
+ end
72
+
73
+ if # selectedUnits == 0 then
74
+ return " 0 " .. L ( " time.seconds" )
75
+ end
76
76
77
- return table.concat ( parts , " , " )
77
+ local parts = {}
78
+
79
+ for _ , unit in ipairs ( selectedUnits ) do
80
+ table.insert ( parts , unit .value .. " " .. L ( unit .name ) )
81
+ end
82
+
83
+ return table.concat ( parts , " , " )
84
+ end
78
85
end
79
86
80
87
function CustomChat .PrintMessage ( text )
0 commit comments