1/*
2 * Copyright (C) 2009 Petri Damstén <damu@iki.fi>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include "timeunit.h"
21#include "converter.h"
22#include <klocale.h>
23
24using namespace KUnitConversion;
25
26Time::Time() : UnitCategory(TimeCategory)
27{
28 setName(i18n("Time"));
29 setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (time)", "%1 %2"));
30
31 U(Yottasecond, 1e+24,
32 i18nc("time unit symbol", "Ys"),
33 i18nc("unit description in lists", "yottaseconds"),
34 i18nc("unit synonyms for matching user input", "yottasecond;yottaseconds;Ys"),
35 ki18nc("amount in units (real)", "%1 yottaseconds"),
36 ki18ncp("amount in units (integer)", "%1 yottasecond", "%1 yottaseconds")
37 );
38 U(Zettasecond, 1e+21,
39 i18nc("time unit symbol", "Zs"),
40 i18nc("unit description in lists", "zettaseconds"),
41 i18nc("unit synonyms for matching user input", "zettasecond;zettaseconds;Zs"),
42 ki18nc("amount in units (real)", "%1 zettaseconds"),
43 ki18ncp("amount in units (integer)", "%1 zettasecond", "%1 zettaseconds")
44 );
45 U(Exasecond, 1e+18,
46 i18nc("time unit symbol", "Es"),
47 i18nc("unit description in lists", "exaseconds"),
48 i18nc("unit synonyms for matching user input", "exasecond;exaseconds;Es"),
49 ki18nc("amount in units (real)", "%1 exaseconds"),
50 ki18ncp("amount in units (integer)", "%1 exasecond", "%1 exaseconds")
51 );
52 U(Petasecond, 1e+15,
53 i18nc("time unit symbol", "Ps"),
54 i18nc("unit description in lists", "petaseconds"),
55 i18nc("unit synonyms for matching user input", "petasecond;petaseconds;Ps"),
56 ki18nc("amount in units (real)", "%1 petaseconds"),
57 ki18ncp("amount in units (integer)", "%1 petasecond", "%1 petaseconds")
58 );
59 U(Terasecond, 1e+12,
60 i18nc("time unit symbol", "Ts"),
61 i18nc("unit description in lists", "teraseconds"),
62 i18nc("unit synonyms for matching user input", "terasecond;teraseconds;Ts"),
63 ki18nc("amount in units (real)", "%1 teraseconds"),
64 ki18ncp("amount in units (integer)", "%1 terasecond", "%1 teraseconds")
65 );
66 U(Gigasecond, 1e+09,
67 i18nc("time unit symbol", "Gs"),
68 i18nc("unit description in lists", "gigaseconds"),
69 i18nc("unit synonyms for matching user input", "gigasecond;gigaseconds;Gs"),
70 ki18nc("amount in units (real)", "%1 gigaseconds"),
71 ki18ncp("amount in units (integer)", "%1 gigasecond", "%1 gigaseconds")
72 );
73 U(Megasecond, 1e+06,
74 i18nc("time unit symbol", "Ms"),
75 i18nc("unit description in lists", "megaseconds"),
76 i18nc("unit synonyms for matching user input", "megasecond;megaseconds;Ms"),
77 ki18nc("amount in units (real)", "%1 megaseconds"),
78 ki18ncp("amount in units (integer)", "%1 megasecond", "%1 megaseconds")
79 );
80 U(Kilosecond, 1000,
81 i18nc("time unit symbol", "ks"),
82 i18nc("unit description in lists", "kiloseconds"),
83 i18nc("unit synonyms for matching user input", "kilosecond;kiloseconds;ks"),
84 ki18nc("amount in units (real)", "%1 kiloseconds"),
85 ki18ncp("amount in units (integer)", "%1 kilosecond", "%1 kiloseconds")
86 );
87 U(Hectosecond, 100,
88 i18nc("time unit symbol", "hs"),
89 i18nc("unit description in lists", "hectoseconds"),
90 i18nc("unit synonyms for matching user input", "hectosecond;hectoseconds;hs"),
91 ki18nc("amount in units (real)", "%1 hectoseconds"),
92 ki18ncp("amount in units (integer)", "%1 hectosecond", "%1 hectoseconds")
93 );
94 U(Decasecond, 10,
95 i18nc("time unit symbol", "das"),
96 i18nc("unit description in lists", "decaseconds"),
97 i18nc("unit synonyms for matching user input", "decasecond;decaseconds;das"),
98 ki18nc("amount in units (real)", "%1 decaseconds"),
99 ki18ncp("amount in units (integer)", "%1 decasecond", "%1 decaseconds")
100 );
101 setDefaultUnit(UP(Second, 1,
102 i18nc("time unit symbol", "s"),
103 i18nc("unit description in lists", "seconds"),
104 i18nc("unit synonyms for matching user input", "second;seconds;s"),
105 ki18nc("amount in units (real)", "%1 seconds"),
106 ki18ncp("amount in units (integer)", "%1 second", "%1 seconds")
107 ));
108 U(Decisecond, 0.1,
109 i18nc("time unit symbol", "ds"),
110 i18nc("unit description in lists", "deciseconds"),
111 i18nc("unit synonyms for matching user input", "decisecond;deciseconds;ds"),
112 ki18nc("amount in units (real)", "%1 deciseconds"),
113 ki18ncp("amount in units (integer)", "%1 decisecond", "%1 deciseconds")
114 );
115 U(Centisecond, 0.01,
116 i18nc("time unit symbol", "cs"),
117 i18nc("unit description in lists", "centiseconds"),
118 i18nc("unit synonyms for matching user input", "centisecond;centiseconds;cs"),
119 ki18nc("amount in units (real)", "%1 centiseconds"),
120 ki18ncp("amount in units (integer)", "%1 centisecond", "%1 centiseconds")
121 );
122 U(Millisecond, 0.001,
123 i18nc("time unit symbol", "ms"),
124 i18nc("unit description in lists", "milliseconds"),
125 i18nc("unit synonyms for matching user input", "millisecond;milliseconds;ms"),
126 ki18nc("amount in units (real)", "%1 milliseconds"),
127 ki18ncp("amount in units (integer)", "%1 millisecond", "%1 milliseconds")
128 );
129 U(Microsecond, 1e-06,
130 i18nc("time unit symbol", "µs"),
131 i18nc("unit description in lists", "microseconds"),
132 i18nc("unit synonyms for matching user input", "microsecond;microseconds;µs;us"),
133 ki18nc("amount in units (real)", "%1 microseconds"),
134 ki18ncp("amount in units (integer)", "%1 microsecond", "%1 microseconds")
135 );
136 U(Nanosecond, 1e-09,
137 i18nc("time unit symbol", "ns"),
138 i18nc("unit description in lists", "nanoseconds"),
139 i18nc("unit synonyms for matching user input", "nanosecond;nanoseconds;ns"),
140 ki18nc("amount in units (real)", "%1 nanoseconds"),
141 ki18ncp("amount in units (integer)", "%1 nanosecond", "%1 nanoseconds")
142 );
143 U(Picosecond, 1e-12,
144 i18nc("time unit symbol", "ps"),
145 i18nc("unit description in lists", "picoseconds"),
146 i18nc("unit synonyms for matching user input", "picosecond;picoseconds;ps"),
147 ki18nc("amount in units (real)", "%1 picoseconds"),
148 ki18ncp("amount in units (integer)", "%1 picosecond", "%1 picoseconds")
149 );
150 U(Femtosecond, 1e-15,
151 i18nc("time unit symbol", "fs"),
152 i18nc("unit description in lists", "femtoseconds"),
153 i18nc("unit synonyms for matching user input", "femtosecond;femtoseconds;fs"),
154 ki18nc("amount in units (real)", "%1 femtoseconds"),
155 ki18ncp("amount in units (integer)", "%1 femtosecond", "%1 femtoseconds")
156 );
157 U(Attosecond, 1e-18,
158 i18nc("time unit symbol", "as"),
159 i18nc("unit description in lists", "attoseconds"),
160 i18nc("unit synonyms for matching user input", "attosecond;attoseconds;as"),
161 ki18nc("amount in units (real)", "%1 attoseconds"),
162 ki18ncp("amount in units (integer)", "%1 attosecond", "%1 attoseconds")
163 );
164 U(Zeptosecond, 1e-21,
165 i18nc("time unit symbol", "zs"),
166 i18nc("unit description in lists", "zeptoseconds"),
167 i18nc("unit synonyms for matching user input", "zeptosecond;zeptoseconds;zs"),
168 ki18nc("amount in units (real)", "%1 zeptoseconds"),
169 ki18ncp("amount in units (integer)", "%1 zeptosecond", "%1 zeptoseconds")
170 );
171 U(Yoctosecond, 1e-24,
172 i18nc("time unit symbol", "ys"),
173 i18nc("unit description in lists", "yoctoseconds"),
174 i18nc("unit synonyms for matching user input", "yoctosecond;yoctoseconds;ys"),
175 ki18nc("amount in units (real)", "%1 yoctoseconds"),
176 ki18ncp("amount in units (integer)", "%1 yoctosecond", "%1 yoctoseconds")
177 );
178 U(Minute, 60,
179 i18nc("time unit symbol", "min"),
180 i18nc("unit description in lists", "minutes"),
181 i18nc("unit synonyms for matching user input", "minute;minutes;min"),
182 ki18nc("amount in units (real)", "%1 minutes"),
183 ki18ncp("amount in units (integer)", "%1 minute", "%1 minutes")
184 );
185 U(Hour, 3600,
186 i18nc("time unit symbol", "h"),
187 i18nc("unit description in lists", "hours"),
188 i18nc("unit synonyms for matching user input", "hour;hours;h"),
189 ki18nc("amount in units (real)", "%1 hours"),
190 ki18ncp("amount in units (integer)", "%1 hour", "%1 hours")
191 );
192 U(Day, 86400,
193 i18nc("time unit symbol", "d"),
194 i18nc("unit description in lists", "days"),
195 i18nc("unit synonyms for matching user input", "day;days;d"),
196 ki18nc("amount in units (real)", "%1 days"),
197 ki18ncp("amount in units (integer)", "%1 day", "%1 days")
198 );
199 U(Week, 604800,
200 i18nc("time unit symbol", "w"),
201 i18nc("unit description in lists", "weeks"),
202 i18nc("unit synonyms for matching user input", "week;weeks"),
203 ki18nc("amount in units (real)", "%1 weeks"),
204 ki18ncp("amount in units (integer)", "%1 week", "%1 weeks")
205 );
206 U(JulianYear, 3.15576e+07,
207 i18nc("time unit symbol", "a"),
208 i18nc("unit description in lists", "Julian years"),
209 i18nc("unit synonyms for matching user input", "Julian year;Julian years;a"),
210 ki18nc("amount in units (real)", "%1 Julian years"),
211 ki18ncp("amount in units (integer)", "%1 Julian year", "%1 Julian years")
212 );
213 U(LeapYear, 3.16224e+07,
214 i18nc("time unit symbol", "lpy"),
215 i18nc("unit description in lists", "leap years"),
216 i18nc("unit synonyms for matching user input", "leap year;leap years"),
217 ki18nc("amount in units (real)", "%1 leap years"),
218 ki18ncp("amount in units (integer)", "%1 leap year", "%1 leap years")
219 );
220 //Let's say we call that a normal year
221 U(Year, 3.1536e+07,
222 i18nc("time unit symbol", "y"),
223 i18nc("unit description in lists", "year"),
224 i18nc("unit synonyms for matching user input", "year;years;y"),
225 ki18nc("amount in units (real)", "%1 year"),
226 ki18ncp("amount in units (integer)", "%1 year", "%1 years")
227 );
228
229 setMostCommonUnits(QList<int>() << Second << Minute << Day << Week << Year);
230}
231