diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 37333bf25ad9a4c538250f5af2f9f1d666362883 (patch) | |
tree | c45e8df5b9efbffe07eb3d9340df7811c7e16943 /kcron/ctdow.cpp | |
download | tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcron/ctdow.cpp')
-rw-r--r-- | kcron/ctdow.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/kcron/ctdow.cpp b/kcron/ctdow.cpp new file mode 100644 index 0000000..fe93c86 --- /dev/null +++ b/kcron/ctdow.cpp @@ -0,0 +1,99 @@ +/*************************************************************************** + * CT Day Of Week Implementation * + * -------------------------------------------------------------------- * + * Copyright (C) 1999, Gary Meyer <gary@meyer.net> * + * -------------------------------------------------------------------- * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +// Do not introduce any Qt or KDE dependencies into the "CT"-prefixed classes. +// I want to be able to reuse these classes with another GUI toolkit. -GM 11/99 + +#include "ctdow.h" +#include "cti18n.h" + +string CTDayOfWeek::shortName[8] = +{ + "", "", "", "", "", "", "", "" +}; + +string CTDayOfWeek::longName[8] = +{ + "", "", "", "", "", "", "", "" +}; + +CTDayOfWeek::CTDayOfWeek(const string& tokStr) : + CTUnit<1,7>(tokStr) +{ + // Compensate for cron supporting Sunday as both 0 and 7. + + if (get(0)) + { + set(0,false); + set(7,true); + } +} + +void CTDayOfWeek::initialize(const string &tokStr) +{ + CTUnit<1,7>::initialize(tokStr); + + // Compensate for cron supporting Sunday as both 0 and 7. + + if (get(0)) + { + set(0,false); + set(7,true); + apply(); + } +} + +string CTDayOfWeek::describe() const +{ + initializeNames(); + if (count() == 7) + return (const char*)i18n("every day ").local8Bit(); + else if (get(1) && get(2) && get(3) && get(4) && get(5)) + return (const char*)i18n("weekday ").local8Bit(); + else + return CTUnit<1,7>::describe(shortName); +} + +string CTDayOfWeek::getName(const int ndx, const bool format) +{ + initializeNames(); + return (format == shortFormat) ? shortName[ndx] : longName[ndx]; +} + +void CTDayOfWeek::initializeNames() +{ + if (shortName[1].empty()) + { + const string shortDOWName[8] = + { + "", + (const char*)i18n("Mon").local8Bit(), (const char*)i18n("Tue").local8Bit(), + (const char*)i18n("Wed").local8Bit(), (const char*)i18n("Thu").local8Bit(), + (const char*)i18n("Fri").local8Bit(), (const char*)i18n("Sat").local8Bit(), + (const char*)i18n("Sun").local8Bit() + }; + + const string longDOWName[8] = + { + "", + (const char*)i18n("Monday").local8Bit(), (const char*)i18n("Tuesday").local8Bit(), + (const char*)i18n("Wednesday").local8Bit(), (const char*)i18n("Thursday").local8Bit(), + (const char*)i18n("Friday").local8Bit(), (const char*)i18n("Saturday").local8Bit(), + (const char*)i18n("Sunday").local8Bit() + }; + + for (int i = 1; i <= 7; i++) + { + shortName[i] = shortDOWName[i]; + longName[i] = longDOWName[i]; + } + } +} |