Skip to content

Commit

Permalink
Merge pull request #5 from khumnath/devlopment
Browse files Browse the repository at this point in the history
fix errors from windows build
  • Loading branch information
khumnath authored Jun 17, 2024
2 parents 46a695c + 013d906 commit e806534
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
14 changes: 11 additions & 3 deletions bikram.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef BIKRAM_H
#define BIKRAM_H

#include <iostream>
#include <cstring>
#include <ctime>
#include <cmath>
#include <string>
Expand Down Expand Up @@ -152,8 +152,16 @@ inline void bikram::fromNepali(int bsYear, int bsMonth, int bsDay) {
}

inline int bikram::getDayOfWeek() {
std::tm timeinfo = { 0, 0, 0, Day, Month - 1, Year - 1900, 0, 0, 0, 0, "" };
std::tm timeinfo;
std::memset(&timeinfo, 0, sizeof(timeinfo)); // Initialize all members to zero

timeinfo.tm_mday = Day;
timeinfo.tm_mon = Month - 1;
timeinfo.tm_year = Year - 1900;

// Call std::mktime to normalize the tm structure
std::mktime(&timeinfo);

return timeinfo.tm_wday;
}

Expand All @@ -171,7 +179,7 @@ inline int bikram::getDay() {


inline std::string bikram::getWeekdayName(int year, int month, int day) {
std::tm timeinfo = { 0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, "" };
std::tm timeinfo = { 0, 0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0 };
std::mktime(&timeinfo);
const char* weekday[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
return weekday[timeinfo.tm_wday];
Expand Down
13 changes: 11 additions & 2 deletions calendarwindow.ui
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<x>90</x>
<y>50</y>
<width>111</width>
<height>40</height>
<height>41</height>
</rect>
</property>
<property name="font">
Expand All @@ -112,6 +112,9 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="maxVisibleItems">
<number>12</number>
</property>
</widget>
<widget class="QComboBox" name="dayselectAD">
<property name="geometry">
Expand Down Expand Up @@ -155,7 +158,7 @@
<x>390</x>
<y>50</y>
<width>101</width>
<height>40</height>
<height>41</height>
</rect>
</property>
<property name="font">
Expand All @@ -166,6 +169,12 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="maxVisibleItems">
<number>12</number>
</property>
<property name="modelColumn">
<number>0</number>
</property>
</widget>
<widget class="QComboBox" name="dayselectBS">
<property name="geometry">
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <QLocale>
std::string MainWindow::getWeekdayName(int year, int month, int day) {
std::tm timeinfo = { 0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, "" };
std::tm timeinfo = { 0, 0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0};
std::mktime(&timeinfo); // Update timeinfo to fill in the week day field

const std::string nepaliWeekdays[] = { "आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार" };
Expand Down

0 comments on commit e806534

Please sign in to comment.