• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KUnitConversion

timeunit.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2009 Petri Damstén <damu@iki.fi>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include "timeunit.h"
00021 #include "converter.h"
00022 #include <klocale.h>
00023 
00024 using namespace KUnitConversion;
00025 
00026 Time::Time() : UnitCategory(TimeCategory)
00027 {
00028     setName(i18n("Time"));
00029     setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (time)", "%1 %2"));
00030 
00031     U(Yottasecond, 1e+24,
00032       i18nc("time unit symbol", "Ys"),
00033       i18nc("unit description in lists", "yottaseconds"),
00034       i18nc("unit synonyms for matching user input", "yottasecond;yottaseconds;Ys"),
00035       ki18nc("amount in units (real)", "%1 yottaseconds"),
00036       ki18ncp("amount in units (integer)", "%1 yottasecond", "%1 yottaseconds")
00037     );
00038     U(Zettasecond, 1e+21,
00039       i18nc("time unit symbol", "Zs"),
00040       i18nc("unit description in lists", "zettaseconds"),
00041       i18nc("unit synonyms for matching user input", "zettasecond;zettaseconds;Zs"),
00042       ki18nc("amount in units (real)", "%1 zettaseconds"),
00043       ki18ncp("amount in units (integer)", "%1 zettasecond", "%1 zettaseconds")
00044     );
00045     U(Exasecond, 1e+18,
00046       i18nc("time unit symbol", "Es"),
00047       i18nc("unit description in lists", "exaseconds"),
00048       i18nc("unit synonyms for matching user input", "exasecond;exaseconds;Es"),
00049       ki18nc("amount in units (real)", "%1 exaseconds"),
00050       ki18ncp("amount in units (integer)", "%1 exasecond", "%1 exaseconds")
00051     );
00052     U(Petasecond, 1e+15,
00053       i18nc("time unit symbol", "Ps"),
00054       i18nc("unit description in lists", "petaseconds"),
00055       i18nc("unit synonyms for matching user input", "petasecond;petaseconds;Ps"),
00056       ki18nc("amount in units (real)", "%1 petaseconds"),
00057       ki18ncp("amount in units (integer)", "%1 petasecond", "%1 petaseconds")
00058     );
00059     U(Terasecond, 1e+12,
00060       i18nc("time unit symbol", "Ts"),
00061       i18nc("unit description in lists", "teraseconds"),
00062       i18nc("unit synonyms for matching user input", "terasecond;teraseconds;Ts"),
00063       ki18nc("amount in units (real)", "%1 teraseconds"),
00064       ki18ncp("amount in units (integer)", "%1 terasecond", "%1 teraseconds")
00065     );
00066     U(Gigasecond, 1e+09,
00067       i18nc("time unit symbol", "Gs"),
00068       i18nc("unit description in lists", "gigaseconds"),
00069       i18nc("unit synonyms for matching user input", "gigasecond;gigaseconds;Gs"),
00070       ki18nc("amount in units (real)", "%1 gigaseconds"),
00071       ki18ncp("amount in units (integer)", "%1 gigasecond", "%1 gigaseconds")
00072     );
00073     U(Megasecond, 1e+06,
00074       i18nc("time unit symbol", "Ms"),
00075       i18nc("unit description in lists", "megaseconds"),
00076       i18nc("unit synonyms for matching user input", "megasecond;megaseconds;Ms"),
00077       ki18nc("amount in units (real)", "%1 megaseconds"),
00078       ki18ncp("amount in units (integer)", "%1 megasecond", "%1 megaseconds")
00079     );
00080     U(Kilosecond, 1000,
00081       i18nc("time unit symbol", "ks"),
00082       i18nc("unit description in lists", "kiloseconds"),
00083       i18nc("unit synonyms for matching user input", "kilosecond;kiloseconds;ks"),
00084       ki18nc("amount in units (real)", "%1 kiloseconds"),
00085       ki18ncp("amount in units (integer)", "%1 kilosecond", "%1 kiloseconds")
00086     );
00087     U(Hectosecond, 100,
00088       i18nc("time unit symbol", "hs"),
00089       i18nc("unit description in lists", "hectoseconds"),
00090       i18nc("unit synonyms for matching user input", "hectosecond;hectoseconds;hs"),
00091       ki18nc("amount in units (real)", "%1 hectoseconds"),
00092       ki18ncp("amount in units (integer)", "%1 hectosecond", "%1 hectoseconds")
00093     );
00094     U(Decasecond, 10,
00095       i18nc("time unit symbol", "das"),
00096       i18nc("unit description in lists", "decaseconds"),
00097       i18nc("unit synonyms for matching user input", "decasecond;decaseconds;das"),
00098       ki18nc("amount in units (real)", "%1 decaseconds"),
00099       ki18ncp("amount in units (integer)", "%1 decasecond", "%1 decaseconds")
00100     );
00101     setDefaultUnit(UP(Second, 1,
00102       i18nc("time unit symbol", "s"),
00103       i18nc("unit description in lists", "seconds"),
00104       i18nc("unit synonyms for matching user input", "second;seconds;s"),
00105       ki18nc("amount in units (real)", "%1 seconds"),
00106       ki18ncp("amount in units (integer)", "%1 second", "%1 seconds")
00107     ));
00108     U(Decisecond, 0.1,
00109       i18nc("time unit symbol", "ds"),
00110       i18nc("unit description in lists", "deciseconds"),
00111       i18nc("unit synonyms for matching user input", "decisecond;deciseconds;ds"),
00112       ki18nc("amount in units (real)", "%1 deciseconds"),
00113       ki18ncp("amount in units (integer)", "%1 decisecond", "%1 deciseconds")
00114     );
00115     U(Centisecond, 0.01,
00116       i18nc("time unit symbol", "cs"),
00117       i18nc("unit description in lists", "centiseconds"),
00118       i18nc("unit synonyms for matching user input", "centisecond;centiseconds;cs"),
00119       ki18nc("amount in units (real)", "%1 centiseconds"),
00120       ki18ncp("amount in units (integer)", "%1 centisecond", "%1 centiseconds")
00121     );
00122     U(Millisecond, 0.001,
00123       i18nc("time unit symbol", "ms"),
00124       i18nc("unit description in lists", "milliseconds"),
00125       i18nc("unit synonyms for matching user input", "millisecond;milliseconds;ms"),
00126       ki18nc("amount in units (real)", "%1 milliseconds"),
00127       ki18ncp("amount in units (integer)", "%1 millisecond", "%1 milliseconds")
00128     );
00129     U(Microsecond, 1e-06,
00130       i18nc("time unit symbol", "µs"),
00131       i18nc("unit description in lists", "microseconds"),
00132       i18nc("unit synonyms for matching user input", "microsecond;microseconds;µs;us"),
00133       ki18nc("amount in units (real)", "%1 microseconds"),
00134       ki18ncp("amount in units (integer)", "%1 microsecond", "%1 microseconds")
00135     );
00136     U(Nanosecond, 1e-09,
00137       i18nc("time unit symbol", "ns"),
00138       i18nc("unit description in lists", "nanoseconds"),
00139       i18nc("unit synonyms for matching user input", "nanosecond;nanoseconds;ns"),
00140       ki18nc("amount in units (real)", "%1 nanoseconds"),
00141       ki18ncp("amount in units (integer)", "%1 nanosecond", "%1 nanoseconds")
00142     );
00143     U(Picosecond, 1e-12,
00144       i18nc("time unit symbol", "ps"),
00145       i18nc("unit description in lists", "picoseconds"),
00146       i18nc("unit synonyms for matching user input", "picosecond;picoseconds;ps"),
00147       ki18nc("amount in units (real)", "%1 picoseconds"),
00148       ki18ncp("amount in units (integer)", "%1 picosecond", "%1 picoseconds")
00149     );
00150     U(Femtosecond, 1e-15,
00151       i18nc("time unit symbol", "fs"),
00152       i18nc("unit description in lists", "femtoseconds"),
00153       i18nc("unit synonyms for matching user input", "femtosecond;femtoseconds;fs"),
00154       ki18nc("amount in units (real)", "%1 femtoseconds"),
00155       ki18ncp("amount in units (integer)", "%1 femtosecond", "%1 femtoseconds")
00156     );
00157     U(Attosecond, 1e-18,
00158       i18nc("time unit symbol", "as"),
00159       i18nc("unit description in lists", "attoseconds"),
00160       i18nc("unit synonyms for matching user input", "attosecond;attoseconds;as"),
00161       ki18nc("amount in units (real)", "%1 attoseconds"),
00162       ki18ncp("amount in units (integer)", "%1 attosecond", "%1 attoseconds")
00163     );
00164     U(Zeptosecond, 1e-21,
00165       i18nc("time unit symbol", "zs"),
00166       i18nc("unit description in lists", "zeptoseconds"),
00167       i18nc("unit synonyms for matching user input", "zeptosecond;zeptoseconds;zs"),
00168       ki18nc("amount in units (real)", "%1 zeptoseconds"),
00169       ki18ncp("amount in units (integer)", "%1 zeptosecond", "%1 zeptoseconds")
00170     );
00171     U(Yoctosecond, 1e-24,
00172       i18nc("time unit symbol", "ys"),
00173       i18nc("unit description in lists", "yoctoseconds"),
00174       i18nc("unit synonyms for matching user input", "yoctosecond;yoctoseconds;ys"),
00175       ki18nc("amount in units (real)", "%1 yoctoseconds"),
00176       ki18ncp("amount in units (integer)", "%1 yoctosecond", "%1 yoctoseconds")
00177     );
00178     U(Minute, 60,
00179       i18nc("time unit symbol", "min"),
00180       i18nc("unit description in lists", "minutes"),
00181       i18nc("unit synonyms for matching user input", "minute;minutes;min"),
00182       ki18nc("amount in units (real)", "%1 minutes"),
00183       ki18ncp("amount in units (integer)", "%1 minute", "%1 minutes")
00184     );
00185     U(Hour, 3600,
00186       i18nc("time unit symbol", "h"),
00187       i18nc("unit description in lists", "hours"),
00188       i18nc("unit synonyms for matching user input", "hour;hours;h"),
00189       ki18nc("amount in units (real)", "%1 hours"),
00190       ki18ncp("amount in units (integer)", "%1 hour", "%1 hours")
00191     );
00192     U(Day, 86400,
00193       i18nc("time unit symbol", "d"),
00194       i18nc("unit description in lists", "days"),
00195       i18nc("unit synonyms for matching user input", "day;days;d"),
00196       ki18nc("amount in units (real)", "%1 days"),
00197       ki18ncp("amount in units (integer)", "%1 day", "%1 days")
00198     );
00199     U(Week, 604800,
00200       i18nc("time unit symbol", "w"),
00201       i18nc("unit description in lists", "weeks"),
00202       i18nc("unit synonyms for matching user input", "week;weeks"),
00203       ki18nc("amount in units (real)", "%1 weeks"),
00204       ki18ncp("amount in units (integer)", "%1 week", "%1 weeks")
00205     );
00206     U(JulianYear, 3.15576e+07,
00207       i18nc("time unit symbol", "a"),
00208       i18nc("unit description in lists", "Julian years"),
00209       i18nc("unit synonyms for matching user input", "Julian year;Julian years;a"),
00210       ki18nc("amount in units (real)", "%1 Julian years"),
00211       ki18ncp("amount in units (integer)", "%1 Julian year", "%1 Julian years")
00212     );
00213     U(LeapYear, 3.16224e+07,
00214       i18nc("time unit symbol", "lpy"),
00215       i18nc("unit description in lists", "leap years"),
00216       i18nc("unit synonyms for matching user input", "leap year;leap years"),
00217       ki18nc("amount in units (real)", "%1 leap years"),
00218       ki18ncp("amount in units (integer)", "%1 leap year", "%1 leap years")
00219     );
00220     //Let's say we call that a normal year
00221     U(Year, 3.1536e+07,
00222       i18nc("time unit symbol", "y"),
00223       i18nc("unit description in lists", "year"),
00224       i18nc("unit synonyms for matching user input", "year;years;y"),
00225       ki18nc("amount in units (real)", "%1 year"),
00226       ki18ncp("amount in units (integer)", "%1 year", "%1 years")
00227     );
00228 
00229     setMostCommonUnits(QList<int>() << Second << Minute << Day << Week << Year);
00230 }

KUnitConversion

Skip menu "KUnitConversion"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal