Skip to content

Commit 963b1fd

Browse files
committed
adress build errors
1 parent 0e332ce commit 963b1fd

File tree

11 files changed

+78
-42
lines changed

11 files changed

+78
-42
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ set(NEPDATE_WIDGET_SOURCES
5757
calendarwindow.cpp
5858
calendarlogic.cpp
5959
calendartable.cpp
60-
convertor.cpp
60+
converter.cpp
6161
panchanga.cpp
6262
)
6363

@@ -69,7 +69,7 @@ set(NEPDATE_WIDGET_HEADERS
6969
calendarwindow.h
7070
calendarlogic.h
7171
calendartable.h
72-
convertor.h
72+
converter.h
7373
)
7474

7575
set(NEPDATE_WIDGET_FORMS
@@ -95,7 +95,7 @@ set(NEPDATE_CALENDAR_SOURCES
9595
mainwindow.cpp
9696
calendarlogic.cpp
9797
calendartable.cpp
98-
convertor.cpp
98+
converter.cpp
9999
panchanga.cpp
100100
)
101101

@@ -105,10 +105,9 @@ set(NEPDATE_CALENDAR_HEADERS
105105
bikram.h
106106
mainwindow.h
107107
panchanga.h
108-
calendarwindow.h
109108
calendarlogic.h
110109
calendartable.h
111-
convertor.h
110+
converter.h
112111
)
113112

114113
set(NEPDATE_CALENDAR_FORMS

DayTithiWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include <QtGlobal>
1414
#include <QMouseEvent>
1515
#include <QMessageBox>
16-
#include "panchanga.h"
1716
#include "bikram.h"
1817
#include <QDate>
1918
#include "calendarlogic.h"
19+
#include "panchanga.h"
2020

2121
class DayTithiWidget : public QWidget {
2222
Q_OBJECT

bikram.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef BIKRAM_H
22
#define BIKRAM_H
33

4-
#include "panchanga.h"
5-
64
#include <cmath>
75

86
class Bikram {

calendartable.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "calendartable.h"
22
#include "DayTithiWidget.h"
33
#include "calendarlogic.h"
4-
#include "panchanga.h"
54
#include <QComboBox>
65
#include <QHeaderView>
76
#include <QIcon>
87
#include <QDate>
98
#include <QTableWidgetItem>
109
#include <QTableWidget>
10+
#include "panchanga.h"
1111

1212
void CalendarTableHelper::updateCalendar(QTableWidget* table, Bikram& converter, int year, int month, int& gYear, int& gMonth, int& gDay) {
1313
int daysInMonth = converter.daysInMonth(year, month);
@@ -46,7 +46,11 @@ void CalendarTableHelper::updateCalendar(QTableWidget* table, Bikram& converter,
4646
customWidget->setProperty("year", cellGYear);
4747
customWidget->setProperty("month", cellGMonth);
4848
customWidget->setProperty("gDay", cellGDay); // Store actual Gregorian day
49-
TithiResult tithiResult = calculateTithi({cellGYear - 1900, cellGMonth - 1, cellGDay});
49+
std::tm date_to_pass = {}; // This zero-initializes all members of the struct
50+
date_to_pass.tm_year = cellGYear - 1900;
51+
date_to_pass.tm_mon = cellGMonth - 1;
52+
date_to_pass.tm_mday = cellGDay;
53+
TithiResult tithiResult = calculateTithi(date_to_pass);
5054
QString tooltipText = QString("%1 (%2)")
5155
.arg(QString::fromStdString(tithiResult.tithiName))
5256
.arg(QString::fromStdString(tithiResult.paksha));

calendarwindow.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "DayTithiWidget.h"
2-
#include "panchanga.h"
32
#include "ui_calendarwindow.h"
43
#include "calendarwindow.h"
54
#include "bikram.h"
@@ -18,7 +17,8 @@
1817
#include <QSettings>
1918
#include <QCloseEvent>
2019
#include <QTimer>
21-
#include "convertor.h"
20+
#include "converter.h"
21+
#include "panchanga.h"
2222

2323
CalendarWindow::CalendarWindow(QWidget *parent) :
2424
QMainWindow(parent),
@@ -503,7 +503,6 @@ void CalendarWindow::updateBsDateFromAd(int year, int month, int day) {
503503
QString bsMonthName = getBikramMonthName(bs.month);
504504
AdDate ad;
505505
bsToAd(bs.year, bs.month, bs.day, ad);
506-
double julianDate = toJulian(ad.year, ad.month, ad.day);
507506
QString paksha;
508507
QString tithiName = getTithiName(ad.year, ad.month, ad.day, paksha);
509508
QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName);
@@ -539,7 +538,6 @@ void CalendarWindow::updateAdDateFromBs(int year, int month, int day) {
539538
ui->dayselectAD->setCurrentText(QString::number(ad.day));
540539
int bsDaysInMonth = Bikram().daysInMonth(year, month);
541540
QString gmonthname = getEnglishMonthName(ad.month);
542-
double julianDate = toJulian(ad.year, ad.month, ad.day);
543541
QString paksha;
544542
QString tithiName = getTithiName(ad.year, ad.month, ad.day, paksha);
545543
QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName);

convertor.cpp renamed to converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "convertor.h"
2-
1+
#include "converter.h"
2+
#include "panchanga.h"
33
double toJulian(int year, int month, int day) {
44
return gregorianToJulian(year, month, day);
55
}

convertor.h renamed to converter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CONVERTOR_H
33
#include <QString>
44
#include "bikram.h"
5-
#include "panchanga.h"
65

76
struct BsDate {
87
int year;

nepdate-calendar.pro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ TEMPLATE = app
1111
TARGET = nepdate-calendar
1212
SOURCES += main_calendar.cpp \
1313
calendarwindow.cpp \
14-
mainwindow.cpp
14+
mainwindow.cpp \
15+
calendarlogic.cpp \
16+
calendartable.cpp \
17+
converter.cpp \
18+
panchanga.cpp
1519

1620
HEADERS += calendarwindow.h \
1721
DayTithiWidget.h \
1822
bikram.h \
1923
mainwindow.h \
20-
panchanga.h
24+
panchanga.h \
25+
calendarlogic.h \
26+
calendartable.h \
27+
converter.h
2128

2229
FORMS += calendarwindow.ui \
2330
mainwindow.ui

nepdate-widget.pro

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ SOURCES += main.cpp \
1313
mainwindow.cpp \
1414
calendarlogic.cpp \
1515
calendartable.cpp \
16-
convertor.cpp \
16+
converter.cpp \
1717
panchanga.cpp
1818

1919
HEADERS += mainwindow.h \
2020
calendarwindow.h \
2121
calendarlogic.h \
2222
calendartable.h \
23-
convertor.h \
23+
converter.h \
2424
bikram.h \
2525
DayTithiWidget.h \
2626
panchanga.h
@@ -29,6 +29,3 @@ FORMS += mainwindow.ui \
2929
calendarwindow.ui
3030
RESOURCES += \
3131
resources.qrc
32-
33-
DISTFILES += \
34-
resources/Laila-Regular.ttf

panchanga.cpp

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
#include <sstream>
55
#include <iomanip>
66

7+
const char* tithi[] = { "प्रतिपदा", "द्वितीया", "तृतीया", "चतुर्थी", "पञ्चमी", "षष्ठी", "सप्तमी", "अष्टमी", "नवमी", "दशमी", "एकादशी", "द्वादशी", "त्रयोदशी", "चतुर्दशी", "पूर्णिमा", "प्रतिपदा", "द्वितीया", "तृतीया", "चतुर्थी", "पञ्चमी", "षष्ठी", "सप्तमी", "अष्टमी", "नवमी", "दशमी", "एकादशी", "द्वादशी", "त्रयोदशी", "चतुर्दशी", "औंसी" };
8+
const char* paksha[] = { "शुक्ल पक्ष", "कृष्ण पक्ष" };
9+
const char* nakshatra[] = { "अश्विनी", "भरणी", "कृत्तिका", "रोहिणी", "मृगशिरा", "आर्द्रा", "पुनर्वसु", "पुष्य", "आश्रेषा", "मघा", "पूर्वा फाल्गुनी", "उत्तर फाल्गुनी", "हस्त", "चित्रा", "स्वाति", "विशाखा", "अनुराधा", "ज्येष्ठा", "मूला", "पूर्वाषाढा", "उत्तराषाढा", "श्रवण", "श्रविष्ठा", "शतभिषा", "पूर्वा भाद्रपदा", "उत्तर भाद्रपदा", "रेवती" };
10+
const char* rashi[] = { "मेष", "वृष", "मिथुन", "कर्कट", "सिंह", "कन्या", "तुला", "वृश्चिक", "धनु", "मकर", "कुम्भ", "मीन" };
11+
const char* karan[] = { "बव", "बालव", "कौलव", "तैतिल", "गर", "वणिज", "विष्टि", "शकुनि", "चतुष्पद", "नाग", "किंस्तुघ्न" };
12+
const char* yoga[] = { "विष्कुम्भ", "प्रीति", "आयुष्मान्", "सौभाग्य", "शोभन", "अतिगण्ड", "सुकर्मा", "धृति", "शूल", "गण्ड", "वृद्धि", "ध्रुव", "व्याघात", "हर्षण", "वज्र", "सिद्धि", "व्यतीपात", "वरीयान्", "परिघ", "शिव", "सिद्ध", "साध्य", "शुभ", "शुक्ल", "ब्रह्म", "इन्द्र", "वैधृति" };
13+
14+
15+
16+
// --- Utility functions (defined outside the Panchang class) ---
17+
718
std::string formatAMPM(int hours, int minutes) {
819
int h_12 = hours % 12;
920
if (h_12 == 0) h_12 = 12;
@@ -86,9 +97,11 @@ TithiResult calculateTithi(const std::tm& date) {
8697
int sunriseHour = std::stoi(sunriseStr.substr(0, 2));
8798
int sunriseMin = std::stoi(sunriseStr.substr(3, 2));
8899
double jdAtSunrise = julianDay(year, month, day, sunriseHour + sunriseMin / 60.0, NEPAL_OFFSET);
89-
// double d_days_since_j2000 = jdAtSunrise - 2451543.5;
90-
// For simplicity, use the Panchang class for tithi index
100+
101+
// Create a Panchang object and let its constructor and methods do the calculation
91102
Panchang p(jdAtSunrise);
103+
104+
// Now you can safely access the calculated members of the Panchang object
92105
int tithiIndex = static_cast<int>(p.tithi_index);
93106
int pakshaIndex = tithiIndex < 15 ? 0 : 1;
94107
return {tithiIndex, tithi[tithiIndex], paksha[pakshaIndex], pakshaIndex};
@@ -158,8 +171,13 @@ RashiResult calculateRashi(const std::tm& date) {
158171
return {rashiIndex, rashi[rashiIndex]};
159172
}
160173

161-
double getSunLongitude(double d) {
162-
// Based on the TypeScript logic
174+
// --- Member functions for the Panchang class ---
175+
176+
// Correctly define this as a member function of Panchang
177+
// It uses the 'Panchang::' scope resolution operator.
178+
double Panchang::getSunLongitude() {
179+
// Use the class's member variable 'tdays' directly
180+
double d = tdays;
163181
double w = 282.9404 + 4.70935e-5 * d;
164182
double e = 0.016709 - 1.151e-9 * d;
165183
double M = REV(356.0470 + 0.9856002585 * d);
@@ -170,7 +188,11 @@ double getSunLongitude(double d) {
170188
return REV(v + w);
171189
}
172190

173-
double getMoonLongitude(double d) {
191+
// Correctly define this as a member function of Panchang
192+
// It uses the 'Panchang::' scope resolution operator.
193+
double Panchang::getMoonLongitude() {
194+
// Use the class's member variable 'tdays' directly
195+
double d = tdays;
174196
double N = REV(125.1228 - 0.0529538083 * d);
175197
double i = 5.1454;
176198
double w = REV(318.0634 + 0.1643573223 * d);
@@ -187,7 +209,8 @@ double getMoonLongitude(double d) {
187209
double yh = r_dist * (sin(N * D2R) * cos((v_true_anomaly + w) * D2R) + cos(N * D2R) * sin((v_true_anomaly + w) * D2R) * cos(i * D2R));
188210
double moonLon = REV(R2D * atan2(yh, xh));
189211
// Periodic corrections (simplified, as in TS)
190-
double D_elong = REV(L0 - getSunLongitude(d));
212+
// NOTE: This correctly calls the member function getSunLongitude()
213+
double D_elong = REV(L0 - getSunLongitude());
191214
double Ms_global = REV(356.0470 + 0.9856002585 * d);
192215
moonLon += -1.274 * sin((M - 2 * D_elong) * D2R);
193216
moonLon += +0.658 * sin((2 * D_elong) * D2R);
@@ -204,6 +227,22 @@ double getMoonLongitude(double d) {
204227
return REV(moonLon);
205228
}
206229

230+
// Correct implementation of the Panchang class method
207231
void Panchang::calculateTithi() {
208-
TithiResult calculateTithi(const std::tm& date);
232+
double sunLongitude = getSunLongitude();
233+
double moonLongitude = getMoonLongitude();
234+
235+
// Calculate the difference in longitude and normalize it
236+
double tithiElongation = REV(moonLongitude - sunLongitude);
237+
238+
// Calculate the tithi index (360 degrees / 12 degrees per tithi = 30 tithis)
239+
tithi_index = std::floor(tithiElongation / 12.0);
240+
241+
// Determine the Paksha (bright or dark half of the lunar month)
242+
// The first 15 tithis are Shukla Paksha (bright), the next 15 are Krishna Paksha (dark)
243+
if (tithi_index < 15) {
244+
paksha = "शुक्ल पक्ष"; // Shukla Paksha
245+
} else {
246+
paksha = "कृष्ण पक्ष"; // Krishna Paksha
247+
}
209248
}

0 commit comments

Comments
 (0)