| 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 | |
| 13 | namespace KUnitConversion |
| 14 | { |
| 15 | UnitCategory Time::makeCategory() |
| 16 | { |
| 17 | auto c = UnitCategoryPrivate::makeCategory(id: TimeCategory, i18n("Time" ), i18n("Time" )); |
| 18 | auto d = UnitCategoryPrivate::get(category: c); |
| 19 | KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (time)" , "%1 %2" ); |
| 20 | |
| 21 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 22 | id: Yottasecond, |
| 23 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 32 | id: Zettasecond, |
| 33 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 42 | id: Exasecond, |
| 43 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 52 | id: Petasecond, |
| 53 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 62 | id: Terasecond, |
| 63 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 72 | id: Gigasecond, |
| 73 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 82 | id: Megasecond, |
| 83 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 92 | id: Kilosecond, |
| 93 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 102 | id: Hectosecond, |
| 103 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 112 | id: Decasecond, |
| 113 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 122 | id: Second, |
| 123 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 132 | id: Decisecond, |
| 133 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 142 | id: Centisecond, |
| 143 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 152 | id: Millisecond, |
| 153 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 162 | id: Microsecond, |
| 163 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 172 | id: Nanosecond, |
| 173 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 182 | id: Picosecond, |
| 183 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 192 | id: Femtosecond, |
| 193 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 202 | id: Attosecond, |
| 203 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 212 | id: Zeptosecond, |
| 213 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 222 | id: Yoctosecond, |
| 223 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 232 | id: Minute, |
| 233 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 242 | id: Hour, |
| 243 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 252 | id: Day, |
| 253 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 262 | id: Week, |
| 263 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 272 | id: JulianYear, |
| 273 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 282 | id: LeapYear, |
| 283 | multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: TimeCategory, |
| 293 | id: Year, |
| 294 | multiplier: 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 |
| 306 | |