KUnitConversion

timeunit.cpp
1/*
2 * SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
3 * SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#include "timeunit_p.h"
9#include "unit_p.h"
10
11#include <KLocalizedString>
12
13namespace KUnitConversion
14{
15UnitCategory Time::makeCategory()
16{
17 auto c = UnitCategoryPrivate::makeCategory(TimeCategory, i18n("Time"), i18n("Time"));
18 auto d = UnitCategoryPrivate::get(c);
19 KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (time)", "%1 %2");
20
21 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
22 Yottasecond,
23 1e+24,
24 i18nc("time unit symbol", "Ys"),
25 i18nc("unit description in lists", "yottaseconds"),
26 i18nc("unit synonyms for matching user input", "yottasecond;yottaseconds;Ys"),
27 symbolString,
28 ki18nc("amount in units (real)", "%1 yottaseconds"),
29 ki18ncp("amount in units (integer)", "%1 yottasecond", "%1 yottaseconds")));
30
31 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
32 Zettasecond,
33 1e+21,
34 i18nc("time unit symbol", "Zs"),
35 i18nc("unit description in lists", "zettaseconds"),
36 i18nc("unit synonyms for matching user input", "zettasecond;zettaseconds;Zs"),
37 symbolString,
38 ki18nc("amount in units (real)", "%1 zettaseconds"),
39 ki18ncp("amount in units (integer)", "%1 zettasecond", "%1 zettaseconds")));
40
41 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
42 Exasecond,
43 1e+18,
44 i18nc("time unit symbol", "Es"),
45 i18nc("unit description in lists", "exaseconds"),
46 i18nc("unit synonyms for matching user input", "exasecond;exaseconds;Es"),
47 symbolString,
48 ki18nc("amount in units (real)", "%1 exaseconds"),
49 ki18ncp("amount in units (integer)", "%1 exasecond", "%1 exaseconds")));
50
51 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
52 Petasecond,
53 1e+15,
54 i18nc("time unit symbol", "Ps"),
55 i18nc("unit description in lists", "petaseconds"),
56 i18nc("unit synonyms for matching user input", "petasecond;petaseconds;Ps"),
57 symbolString,
58 ki18nc("amount in units (real)", "%1 petaseconds"),
59 ki18ncp("amount in units (integer)", "%1 petasecond", "%1 petaseconds")));
60
61 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
62 Terasecond,
63 1e+12,
64 i18nc("time unit symbol", "Ts"),
65 i18nc("unit description in lists", "teraseconds"),
66 i18nc("unit synonyms for matching user input", "terasecond;teraseconds;Ts"),
67 symbolString,
68 ki18nc("amount in units (real)", "%1 teraseconds"),
69 ki18ncp("amount in units (integer)", "%1 terasecond", "%1 teraseconds")));
70
71 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
72 Gigasecond,
73 1e+09,
74 i18nc("time unit symbol", "Gs"),
75 i18nc("unit description in lists", "gigaseconds"),
76 i18nc("unit synonyms for matching user input", "gigasecond;gigaseconds;Gs"),
77 symbolString,
78 ki18nc("amount in units (real)", "%1 gigaseconds"),
79 ki18ncp("amount in units (integer)", "%1 gigasecond", "%1 gigaseconds")));
80
81 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
82 Megasecond,
83 1e+06,
84 i18nc("time unit symbol", "Ms"),
85 i18nc("unit description in lists", "megaseconds"),
86 i18nc("unit synonyms for matching user input", "megasecond;megaseconds;Ms"),
87 symbolString,
88 ki18nc("amount in units (real)", "%1 megaseconds"),
89 ki18ncp("amount in units (integer)", "%1 megasecond", "%1 megaseconds")));
90
91 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
92 Kilosecond,
93 1000,
94 i18nc("time unit symbol", "ks"),
95 i18nc("unit description in lists", "kiloseconds"),
96 i18nc("unit synonyms for matching user input", "kilosecond;kiloseconds;ks"),
97 symbolString,
98 ki18nc("amount in units (real)", "%1 kiloseconds"),
99 ki18ncp("amount in units (integer)", "%1 kilosecond", "%1 kiloseconds")));
100
101 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
102 Hectosecond,
103 100,
104 i18nc("time unit symbol", "hs"),
105 i18nc("unit description in lists", "hectoseconds"),
106 i18nc("unit synonyms for matching user input", "hectosecond;hectoseconds;hs"),
107 symbolString,
108 ki18nc("amount in units (real)", "%1 hectoseconds"),
109 ki18ncp("amount in units (integer)", "%1 hectosecond", "%1 hectoseconds")));
110
111 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
112 Decasecond,
113 10,
114 i18nc("time unit symbol", "das"),
115 i18nc("unit description in lists", "decaseconds"),
116 i18nc("unit synonyms for matching user input", "decasecond;decaseconds;das"),
117 symbolString,
118 ki18nc("amount in units (real)", "%1 decaseconds"),
119 ki18ncp("amount in units (integer)", "%1 decasecond", "%1 decaseconds")));
120
121 d->addDefaultUnit(UnitPrivate::makeUnit(TimeCategory,
122 Second,
123 1,
124 i18nc("time unit symbol", "s"),
125 i18nc("unit description in lists", "seconds"),
126 i18nc("unit synonyms for matching user input", "second;seconds;s"),
127 symbolString,
128 ki18nc("amount in units (real)", "%1 seconds"),
129 ki18ncp("amount in units (integer)", "%1 second", "%1 seconds")));
130
131 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
132 Decisecond,
133 0.1,
134 i18nc("time unit symbol", "ds"),
135 i18nc("unit description in lists", "deciseconds"),
136 i18nc("unit synonyms for matching user input", "decisecond;deciseconds;ds"),
137 symbolString,
138 ki18nc("amount in units (real)", "%1 deciseconds"),
139 ki18ncp("amount in units (integer)", "%1 decisecond", "%1 deciseconds")));
140
141 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
142 Centisecond,
143 0.01,
144 i18nc("time unit symbol", "cs"),
145 i18nc("unit description in lists", "centiseconds"),
146 i18nc("unit synonyms for matching user input", "centisecond;centiseconds;cs"),
147 symbolString,
148 ki18nc("amount in units (real)", "%1 centiseconds"),
149 ki18ncp("amount in units (integer)", "%1 centisecond", "%1 centiseconds")));
150
151 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
152 Millisecond,
153 0.001,
154 i18nc("time unit symbol", "ms"),
155 i18nc("unit description in lists", "milliseconds"),
156 i18nc("unit synonyms for matching user input", "millisecond;milliseconds;ms"),
157 symbolString,
158 ki18nc("amount in units (real)", "%1 milliseconds"),
159 ki18ncp("amount in units (integer)", "%1 millisecond", "%1 milliseconds")));
160
161 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
162 Microsecond,
163 1e-06,
164 i18nc("time unit symbol", "µs"),
165 i18nc("unit description in lists", "microseconds"),
166 i18nc("unit synonyms for matching user input", "microsecond;microseconds;µs;us"),
167 symbolString,
168 ki18nc("amount in units (real)", "%1 microseconds"),
169 ki18ncp("amount in units (integer)", "%1 microsecond", "%1 microseconds")));
170
171 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
172 Nanosecond,
173 1e-09,
174 i18nc("time unit symbol", "ns"),
175 i18nc("unit description in lists", "nanoseconds"),
176 i18nc("unit synonyms for matching user input", "nanosecond;nanoseconds;ns"),
177 symbolString,
178 ki18nc("amount in units (real)", "%1 nanoseconds"),
179 ki18ncp("amount in units (integer)", "%1 nanosecond", "%1 nanoseconds")));
180
181 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
182 Picosecond,
183 1e-12,
184 i18nc("time unit symbol", "ps"),
185 i18nc("unit description in lists", "picoseconds"),
186 i18nc("unit synonyms for matching user input", "picosecond;picoseconds;ps"),
187 symbolString,
188 ki18nc("amount in units (real)", "%1 picoseconds"),
189 ki18ncp("amount in units (integer)", "%1 picosecond", "%1 picoseconds")));
190
191 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
192 Femtosecond,
193 1e-15,
194 i18nc("time unit symbol", "fs"),
195 i18nc("unit description in lists", "femtoseconds"),
196 i18nc("unit synonyms for matching user input", "femtosecond;femtoseconds;fs"),
197 symbolString,
198 ki18nc("amount in units (real)", "%1 femtoseconds"),
199 ki18ncp("amount in units (integer)", "%1 femtosecond", "%1 femtoseconds")));
200
201 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
202 Attosecond,
203 1e-18,
204 i18nc("time unit symbol", "as"),
205 i18nc("unit description in lists", "attoseconds"),
206 i18nc("unit synonyms for matching user input", "attosecond;attoseconds;as"),
207 symbolString,
208 ki18nc("amount in units (real)", "%1 attoseconds"),
209 ki18ncp("amount in units (integer)", "%1 attosecond", "%1 attoseconds")));
210
211 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
212 Zeptosecond,
213 1e-21,
214 i18nc("time unit symbol", "zs"),
215 i18nc("unit description in lists", "zeptoseconds"),
216 i18nc("unit synonyms for matching user input", "zeptosecond;zeptoseconds;zs"),
217 symbolString,
218 ki18nc("amount in units (real)", "%1 zeptoseconds"),
219 ki18ncp("amount in units (integer)", "%1 zeptosecond", "%1 zeptoseconds")));
220
221 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
222 Yoctosecond,
223 1e-24,
224 i18nc("time unit symbol", "ys"),
225 i18nc("unit description in lists", "yoctoseconds"),
226 i18nc("unit synonyms for matching user input", "yoctosecond;yoctoseconds;ys"),
227 symbolString,
228 ki18nc("amount in units (real)", "%1 yoctoseconds"),
229 ki18ncp("amount in units (integer)", "%1 yoctosecond", "%1 yoctoseconds")));
230
231 d->addCommonUnit(UnitPrivate::makeUnit(TimeCategory,
232 Minute,
233 60,
234 i18nc("time unit symbol", "min"),
235 i18nc("unit description in lists", "minutes"),
236 i18nc("unit synonyms for matching user input", "minute;minutes;min"),
237 symbolString,
238 ki18nc("amount in units (real)", "%1 minutes"),
239 ki18ncp("amount in units (integer)", "%1 minute", "%1 minutes")));
240
241 d->addCommonUnit(UnitPrivate::makeUnit(TimeCategory,
242 Hour,
243 3600,
244 i18nc("time unit symbol", "h"),
245 i18nc("unit description in lists", "hours"),
246 i18nc("unit synonyms for matching user input", "hour;hours;h"),
247 symbolString,
248 ki18nc("amount in units (real)", "%1 hours"),
249 ki18ncp("amount in units (integer)", "%1 hour", "%1 hours")));
250
251 d->addCommonUnit(UnitPrivate::makeUnit(TimeCategory,
252 Day,
253 86400,
254 i18nc("time unit symbol", "d"),
255 i18nc("unit description in lists", "days"),
256 i18nc("unit synonyms for matching user input", "day;days;d"),
257 symbolString,
258 ki18nc("amount in units (real)", "%1 days"),
259 ki18ncp("amount in units (integer)", "%1 day", "%1 days")));
260
261 d->addCommonUnit(UnitPrivate::makeUnit(TimeCategory,
262 Week,
263 604800,
264 i18nc("time unit symbol", "w"),
265 i18nc("unit description in lists", "weeks"),
266 i18nc("unit synonyms for matching user input", "week;weeks"),
267 symbolString,
268 ki18nc("amount in units (real)", "%1 weeks"),
269 ki18ncp("amount in units (integer)", "%1 week", "%1 weeks")));
270
271 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
272 JulianYear,
273 3.15576e+07,
274 i18nc("time unit symbol", "a"),
275 i18nc("unit description in lists", "Julian years"),
276 i18nc("unit synonyms for matching user input", "Julian year;Julian years;a"),
277 symbolString,
278 ki18nc("amount in units (real)", "%1 Julian years"),
279 ki18ncp("amount in units (integer)", "%1 Julian year", "%1 Julian years")));
280
281 d->addUnit(UnitPrivate::makeUnit(TimeCategory,
282 LeapYear,
283 3.16224e+07,
284 i18nc("time unit symbol", "lpy"),
285 i18nc("unit description in lists", "leap years"),
286 i18nc("unit synonyms for matching user input", "leap year;leap years"),
287 symbolString,
288 ki18nc("amount in units (real)", "%1 leap years"),
289 ki18ncp("amount in units (integer)", "%1 leap year", "%1 leap years")));
290
291 // Let's say we call that a normal year
292 d->addCommonUnit(UnitPrivate::makeUnit(TimeCategory,
293 Year,
294 3.1536e+07,
295 i18nc("time unit symbol", "y"),
296 i18nc("unit description in lists", "year"),
297 i18nc("unit synonyms for matching user input", "year;years;y"),
298 symbolString,
299 ki18nc("amount in units (real)", "%1 year"),
300 ki18ncp("amount in units (integer)", "%1 year", "%1 years")));
301
302 return c;
303}
304
305} // KUnitConversion namespace
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:53:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.