Source file
src/tawesoft.co.uk/go/humanizex/common.go
Documentation:
src/tawesoft.co.uk/go/humanizex/common.go
1 package humanizex
2
3 var CommonUnits = struct{
4 None Unit
5 Second Unit
6 Meter Unit
7 Byte Unit
8 Bit Unit
9 BitsPerSecond Unit
10 }{
11 None: Unit{"", ""},
12 Second: Unit{"s", "s"},
13 Meter: Unit{"m", "m"},
14 Byte: Unit{"B", "B"},
15 Bit: Unit{"b", "b"},
16 BitsPerSecond: Unit{"bps", "bps"},
17 }
18
19 var CommonFactors = struct{
20
21
22
23
24 Time Factors
25
26
27
28
29 Distance Factors
30
31
32
33 IEC Factors
34
35
36
37 JEDEC Factors
38
39
40
41
42
43 SIBytes Factors
44
45
46 SIUncommon Factors
47
48
49 SI Factors
50 }{
51 Time: Factors{
52 Factors: []Factor{
53 {1, Unit{"s", "s"}, FactorModeReplace},
54 {60, Unit{"min", "min"}, FactorModeReplace},
55 {60 * 60, Unit{"h", "h"}, FactorModeReplace},
56 {24 * 60 * 60, Unit{"d", "d"}, FactorModeReplace},
57 {365.2422 * 24 * 60 * 60, Unit{"y", "y"}, FactorModeReplace},
58 },
59 Components: 2,
60 },
61 Distance: Factors{
62 Factors: []Factor{
63 {1E-9, Unit{"n", "n"}, FactorModeUnitPrefix},
64 {1E-6, Unit{"μ", "u"}, FactorModeUnitPrefix},
65 {1E-3, Unit{"m", "m"}, FactorModeUnitPrefix},
66 {1E-2, Unit{"c", "c"}, FactorModeUnitPrefix},
67 {1, Unit{ "", ""}, FactorModeIdentity},
68 {1000, Unit{"k", "k"}, FactorModeUnitPrefix},
69 },
70 },
71 IEC: Factors{
72 Factors: []Factor{
73 {1, Unit{ "", ""}, FactorModeUnitPrefix},
74 {1024, Unit{"Ki", "Ki"}, FactorModeUnitPrefix},
75 {1024 * 1024, Unit{"Mi", "Mi"}, FactorModeUnitPrefix},
76 {1024 * 1024 * 1024, Unit{"Gi", "Gi"}, FactorModeUnitPrefix},
77 {1024 * 1024 * 1024 * 1024, Unit{"Ti", "Ti"}, FactorModeUnitPrefix},
78 },
79 },
80 JEDEC: Factors{
81 Factors: []Factor{
82 {1, Unit{ "", ""}, FactorModeIdentity},
83 {1024, Unit{"K", "K"}, FactorModeUnitPrefix},
84 {1024 * 1024, Unit{"M", "M"}, FactorModeUnitPrefix},
85 {1024 * 1024 * 1024, Unit{"G", "G"}, FactorModeUnitPrefix},
86 },
87 },
88 SIBytes: Factors{
89 Factors: []Factor{
90 {1, Unit{ "", ""}, FactorModeIdentity},
91 { 1E3, Unit{"k", "k"}, FactorModeUnitPrefix},
92 { 1E3, Unit{"K", "K"}, FactorModeUnitPrefix | FactorModeInputCompat},
93 { 1E6, Unit{"M", "M"}, FactorModeUnitPrefix},
94 { 1E9, Unit{"G", "G"}, FactorModeUnitPrefix},
95 {1E12, Unit{"T", "T"}, FactorModeUnitPrefix},
96 },
97 },
98 SIUncommon: Factors{
99 Factors: []Factor{
100 {1E-9, Unit{"n", "n"}, FactorModeUnitPrefix},
101 {1E-6, Unit{"μ", "u"}, FactorModeUnitPrefix},
102 {1E-3, Unit{"m", "m"}, FactorModeUnitPrefix},
103 {1E-2, Unit{"c", "c"}, FactorModeUnitPrefix},
104 {1E-1, Unit{"d", "d"}, FactorModeUnitPrefix},
105 {1, Unit{ "", ""}, FactorModeIdentity},
106 { 1E1, Unit{"da", "da"}, FactorModeUnitPrefix},
107 { 1E2, Unit{"h", "h"}, FactorModeUnitPrefix},
108 { 1E3, Unit{"k", "k"}, FactorModeUnitPrefix},
109 { 1E6, Unit{"M", "M"}, FactorModeUnitPrefix},
110 { 1E9, Unit{"G", "G"}, FactorModeUnitPrefix},
111 {1E12, Unit{"T", "T"}, FactorModeUnitPrefix},
112 },
113 },
114 SI: Factors{
115 Factors: []Factor{
116 {1E-9, Unit{"n", "n"}, FactorModeUnitPrefix},
117 {1E-6, Unit{"μ", "u"}, FactorModeUnitPrefix},
118 {1E-3, Unit{"m", "m"}, FactorModeUnitPrefix},
119 {1, Unit{ "", ""}, FactorModeIdentity},
120 { 1E3, Unit{"k", "k"}, FactorModeUnitPrefix},
121 { 1E6, Unit{"M", "M"}, FactorModeUnitPrefix},
122 { 1E9, Unit{"G", "G"}, FactorModeUnitPrefix},
123 {1E12, Unit{"T", "T"}, FactorModeUnitPrefix},
124 },
125 },
126 }
127
View as plain text