• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
kcalendarsystemworld.cpp
1 /*
2  Copyright (C) 2023 by Roman Savochenko, <roman@oscada.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the
15  Free Software Foundation, Inc.,
16  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 
20 #include <tqdatetime.h>
21 #include <tqstring.h>
22 #include <tqstringlist.h>
23 #include <math.h>
24 
25 #include <tdeglobal.h>
26 #include <tdelocale.h>
27 #include <kdebug.h>
28 #include <stdio.h>
29 
30 #include "kcalendarsystemworld.h"
31 
32 int KCalendarSystemWorld::year( const TQDate& date ) const
33 {
34  kdDebug(5400) << "World year..." << endl;
35 
36  int y = date.year() + 5508;
37  if(date.month() < 3) y--;
38 
39  return y;
40 }
41 
42 int KCalendarSystemWorld::month( const TQDate& date ) const
43 {
44  kdDebug(5400) << "World month..." << endl;
45 
46  int m = date.month() - 2;
47  if(m <= 0) m += monthsInYear(date);
48 
49  return m;
50 }
51 
52 bool KCalendarSystemWorld::setYMD( TQDate& date, int y, int m, int d ) const
53 {
54  m += 2;
55  if(m > monthsInYear(date)) { m -= monthsInYear(date); y++; }
56  y -= 5508;
57 
58  return date.setYMD(y, m, d);
59 }
60 
61 TQString KCalendarSystemWorld::monthName( int month, int year, bool shortName ) const
62 {
63  Q_UNUSED(year);
64 
65  switch(month) {
66  case 1: return locale()->translate(shortName?"Ber":"Beresen");
67  case 2: return locale()->translate(shortName?"Kvt":"Kviten");
68  case 3: return locale()->translate(shortName?"Trv":"Traven");
69  case 4: return locale()->translate(shortName?"Chrv":"Cherven");
70  case 5: return locale()->translate(shortName?"Lip":"Lipen");
71  case 6: return locale()->translate(shortName?"Serp":"Serpen");
72  case 7: return locale()->translate(shortName?"Vers":"Veresen");
73  case 8: return locale()->translate(shortName?"Jovt":"Jovten");
74  case 9: return locale()->translate(shortName?"Listpd":"Listopad");
75  case 10: return locale()->translate(shortName?"Grud":"Gruden");
76  case 11: return locale()->translate(shortName?"Sich":"Sichen");
77  case 12: return locale()->translate(shortName?"Lut":"Lutij");
78  }
79 
80  return TQString::null;
81 }
82 
83 TQString KCalendarSystemWorld::weekDayName( int weekDay, bool shortName ) const
84 {
85  switch(weekDay) {
86  case 1: return locale()->translate(shortName?"Pon":"Ponedilok");
87  case 2: return locale()->translate(shortName?"Vtr":"Vivtorok");
88  case 3: return locale()->translate(shortName?"Srd":"Sereda");
89  case 4: return locale()->translate(shortName?"Chet":"Chetver");
90  case 5: return locale()->translate(shortName?"Pjtn":"Pjatnica");
91  case 6: return locale()->translate(shortName?"Shbt":"Shobota");
92  case 7: return locale()->translate(shortName?"Nedl":"Nedila");
93  }
94 
95  return TQString::null;
96 }
KCalendarSystemWorld::month
int month(const TQDate &date) const
Gets specific calendar type month for a given gregorian date.
Definition: kcalendarsystemworld.cpp:42
TDELocale::translate
TQString translate(const char *index) const
Translates the string into the corresponding string in the national language, if available.
Definition: tdelocale.cpp:768
KCalendarSystemWorld::weekDayName
TQString weekDayName(const TQDate &date, bool shortName=false) const
Gets specific calendar type week day name.
Definition: kcalendarsystemworld.h:58
KCalendarSystemWorld::monthsInYear
int monthsInYear(const TQDate &date) const
Gets specific calendar type number of month for a given year.
Definition: kcalendarsystemworld.h:47
KCalendarSystemWorld::monthName
TQString monthName(const TQDate &date, bool shortName=false) const
Gets specific calendar type month name for a given gregorian date.
Definition: kcalendarsystemworld.h:54
tdelocale.h
KCalendarSystemWorld::setYMD
bool setYMD(TQDate &date, int y, int m, int d) const
Changes the date's year, month and day.
Definition: kcalendarsystemworld.cpp:52
KCalendarSystemWorld::year
int year(const TQDate &date) const
Gets specific calendar type year for a given gregorian date.
Definition: kcalendarsystemworld.cpp:32
KCalendarSystem::locale
const TDELocale * locale() const
Gets the locale the calendar uses for translations.
Definition: kcalendarsystem.cpp:47
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.