-
-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Kushal997-das:main' into yash/fix-1381
- Loading branch information
Showing
532 changed files
with
65,271 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Comment on Issue Close | ||
|
||
on: | ||
issues: | ||
types: [closed] | ||
|
||
jobs: | ||
greet-on-close: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Greet User | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issue = context.payload.issue; | ||
const issueCreator = issue.user.login; | ||
const issueNumber = issue.number; | ||
const greetingMessage = `Hi @${issueCreator} 👋, your issue #${issueNumber} has been successfully closed ✅. Thank you for your valuable contribution! 🙌`; | ||
github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber, | ||
body: greetingMessage | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Close Old Issues | ||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
close-issues: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Close Old Issues | ||
run: | | ||
open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues?state=open" \ | ||
| jq -r '.[] | .number') | ||
for issue in $open_issues; do | ||
# Get the last updated timestamp of the issue | ||
last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \ | ||
| jq -r '.updated_at') | ||
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 )) | ||
if [ $days_since_update -gt 15 ]; then | ||
curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-d '{"state":"closed"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" | ||
# Add a comment explaining when the issue will be closed | ||
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-d '{"body":"This issue has been automatically closed due to inactivity for over 15 days. If you think it's still important, feel free to reopen it or submit a new issue. Thank you! 😊"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,111 @@ | ||
#include<iostream> | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int a, c, s, i, x, b, l, r, y, m, p; | ||
//Year | ||
std::cout << "Enter the year (from 0 to 1000000000) :"; | ||
std::cin >> b; | ||
if (b<0 || b>1000000000) | ||
{ | ||
std::cout<<"ERROR::The input year is not in range range.\n"<<"EXIT"; | ||
return 1; | ||
} | ||
//Month for which the calender is required | ||
std::cout << "Enter the number of the month(from 1 to 12) :"; | ||
std::cin >> a; | ||
if (a<1 || a>12) | ||
{ | ||
std::cout<<"ERROR::The input month is not in range range.\n"<<"EXIT"; | ||
return 2; | ||
} | ||
//Aplying Julian Calender Algorithm | ||
r = b % 100; | ||
y = (r + (r / 4)) % 7; | ||
//With the help of month number moth name is getting detected | ||
switch (a) | ||
{ | ||
case 1:std::cout << "\t\tJanuary" << std::endl; | ||
m = 0; | ||
break; | ||
case 2:std::cout << "\t\tFebruary" << std::endl; | ||
m = 3; | ||
break; | ||
case 3:std::cout << "\t\tMarch" << std::endl; | ||
m = 3; | ||
break; | ||
case 4:std::cout << "\t\tApril" << std::endl; | ||
m = 6; | ||
break; | ||
case 5:std::cout << "\t\tMay" << std::endl; | ||
m = 1; | ||
break; | ||
case 6:std::cout << "\t\tJune" << std::endl; | ||
m = 4; | ||
break; | ||
case 7:std::cout << "\t\tJuly" << std::endl; | ||
m = 6; | ||
break; | ||
case 8:std::cout << "\t\tAugust" << std::endl; | ||
m = 2; | ||
break; | ||
case 9:std::cout << "\t\tSeptember" << std::endl; | ||
m = 5; | ||
break; | ||
case 10:std::cout << "\t\tOctober" << std::endl; | ||
m = 0; | ||
break; | ||
case 11:std::cout << "\t\tNovember" << std::endl; | ||
m = 3; | ||
break; | ||
case 12:std::cout << "\t\tDecember" << std::endl; | ||
m = 5; | ||
break; | ||
// Constants for year limits | ||
const int MIN_YEAR = 0; | ||
const int MAX_YEAR = 1000000000; | ||
|
||
// Function to get the month name | ||
string getMonthName(int month) { | ||
switch (month) { | ||
case 1: return "January"; | ||
case 2: return "February"; | ||
case 3: return "March"; | ||
case 4: return "April"; | ||
case 5: return "May"; | ||
case 6: return "June"; | ||
case 7: return "July"; | ||
case 8: return "August"; | ||
case 9: return "September"; | ||
case 10: return "October"; | ||
case 11: return "November"; | ||
case 12: return "December"; | ||
default: return ""; // Should never reach here | ||
} | ||
if (b >= 1700 && b < 1800) | ||
c = 4; | ||
if (b >= 1800 && b < 1900) | ||
c = 2; | ||
if (b >= 1900 && b < 2000) | ||
c = 0; | ||
if (b >= 2000 && b < 2100) | ||
c = 6; | ||
if (b >= 2100 && b < 2200) | ||
c = 4; | ||
if (b >= 2200 && b < 2300) | ||
c = 2; | ||
if (b >= 2300 && b < 2400) | ||
c = 0; | ||
l = 0; | ||
if (b % 4 == 0 && b % 100 != 0 || b % 400 == 0) | ||
{ | ||
p = 1; | ||
if (a <= 2) | ||
l = 1; | ||
} | ||
|
||
// Function to check if the year is a leap year | ||
bool isLeapYear(int year) { | ||
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); | ||
} | ||
|
||
// Function to get the century code based on the year | ||
int getCenturyCode(int year) { | ||
if (year >= 1700 && year < 1800) return 4; | ||
if (year >= 1800 && year < 1900) return 2; | ||
if (year >= 1900 && year < 2000) return 0; | ||
if (year >= 2000 && year < 2100) return 6; | ||
if (year >= 2100 && year < 2200) return 4; | ||
if (year >= 2200 && year < 2300) return 2; | ||
return 0; // Default for years >= 2300 | ||
} | ||
|
||
// Function to get the month code for day calculation | ||
int getMonthCode(int month) { | ||
switch (month) { | ||
case 1: return 0; // January | ||
case 2: return 3; // February | ||
case 3: return 3; // March | ||
case 4: return 6; // April | ||
case 5: return 1; // May | ||
case 6: return 4; // June | ||
case 7: return 6; // July | ||
case 8: return 2; // August | ||
case 9: return 5; // September | ||
case 10: return 0; // October | ||
case 11: return 3; // November | ||
case 12: return 5; // December | ||
default: return 0; // Should never reach here | ||
} | ||
else | ||
p = 0; | ||
//Displaying the calender | ||
i = (y + m + c + 1 - l) % 7; | ||
std::cout << "Sun\tMon\tTue\tWed\tThu\tFri\tSat\n"; | ||
for (x = 1; x <= i; x++) | ||
{ | ||
std::cout << "\t"; | ||
} | ||
|
||
int main() { | ||
int year, month; | ||
|
||
// Input for year | ||
cout << "Enter the year (from " << MIN_YEAR << " to " << MAX_YEAR << "): "; | ||
cin >> year; | ||
if (year < MIN_YEAR || year > MAX_YEAR) { | ||
cout << "ERROR: The input year is not in range.\nPlease try again.\n"; | ||
return 1; | ||
} | ||
if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) | ||
{ | ||
for (x = 1; x <= 31; x++) | ||
{ | ||
if (((x + i - 1) % 7 == 0) && (x != 1)) | ||
std::cout << std::endl; | ||
std::cout << x << "\t"; | ||
} | ||
|
||
// Input for month | ||
cout << "Enter the number of the month (from 1 to 12): "; | ||
cin >> month; | ||
if (month < 1 || month > 12) { | ||
cout << "ERROR: The input month is not in range.\nPlease try again.\n"; | ||
return 2; | ||
} | ||
if (a == 4 || a == 6 || a == 9 || a == 11) | ||
{ | ||
for (x = 1; x <= 30; x++) | ||
{ | ||
|
||
if (((x + i - 1) % 7 == 0) && x != 1) | ||
std::cout << std::endl; | ||
std::cout << x << "\t"; | ||
// Calculating the day of the week | ||
int centuryCode = getCenturyCode(year); | ||
int yearCode = year % 100; // Last two digits of the year | ||
int leapAdjustment = (isLeapYear(year) && month <= 2) ? 1 : 0; // Adjust if it's a leap year and before March | ||
int dayOfWeek = (yearCode + (yearCode / 4) + getMonthCode(month) + centuryCode - leapAdjustment) % 7; | ||
|
||
} | ||
// Displaying the calendar | ||
cout << "\n\t\t" << getMonthName(month) << " " << year << endl; | ||
cout << "Sun\tMon\tTue\tWed\tThu\tFri\tSat\n"; | ||
|
||
for (int x = 0; x < dayOfWeek; x++) { | ||
cout << "\t"; // Leading spaces for the first week | ||
} | ||
if (a == 2) | ||
{ | ||
if (p == 0) | ||
{ | ||
for (x = 1; x <= 28; x++) | ||
{ | ||
if (((x + i - 1) % 7 == 0) && (x != 1)) | ||
std::cout << std::endl; | ||
std::cout << x << "\t"; | ||
} | ||
} | ||
else | ||
{ | ||
for (x = 1; x <= 29; x++) | ||
{ | ||
if (((x + i - 1) % 7 == 0) && (x != 1)) | ||
std::cout << std::endl; | ||
std::cout << x << "\t"; | ||
} | ||
|
||
int daysInMonth; | ||
if (month == 2) { | ||
daysInMonth = isLeapYear(year) ? 29 : 28; // February days | ||
} else { | ||
daysInMonth = (month == 4 || month == 6 || month == 9 || month == 11) ? 30 : 31; // Days in other months | ||
} | ||
|
||
for (int day = 1; day <= daysInMonth; day++) { | ||
cout << day << "\t"; | ||
if ((day + dayOfWeek) % 7 == 0) { | ||
cout << endl; // New line after Saturday | ||
} | ||
} | ||
cout << endl; // New line at the end | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
import datetime | ||
|
||
# Get the current system date and time | ||
now = datetime.datetime.now() | ||
key1 = now.year - 18 | ||
key3 = now.month | ||
d1 = datetime.date.today() | ||
num = 0 | ||
|
||
try: | ||
birthday = input("When is your birthday?") | ||
birthday = datetime.datetime.strptime(birthday,"%d/%m/%Y",).date() | ||
key2 = birthday.year+18 | ||
age = now.year - birthday.year | ||
b_month = birthday.month | ||
n_year = now.year | ||
b_year = birthday.year | ||
###################################################################################################################################################################### | ||
while b_year < n_year: | ||
year1 = 12 # 1 year = 12 months | ||
num = num + 1 | ||
b_year = b_year + 1 | ||
num2 = 12 - b_month | ||
months = num * 12 + num2 - 1 | ||
days = now.day - birthday.day | ||
# print(days) | ||
####################################################################################################################################################################### | ||
if birthday <= datetime.date.today() and key2 <= now.year: | ||
print("Your birthday is "+ birthday.strftime('%d, %B %Y'), "and Your Age is", age, "years and", num2-1,"months and", days, "days") | ||
elif age < 0: | ||
print("Date or format is incorrect") | ||
else: | ||
print("You are under 18", "and Your Age is", age, "years and", num2-1,"months and", days, "days") | ||
except: | ||
print("date or format is invalid") | ||
25 | ||
# Take user input of their birth date | ||
birthday = input("When is your birthday? (dd/mm/yyyy): ") | ||
birthday = datetime.datetime.strptime( | ||
birthday, | ||
"%d/%m/%Y", | ||
).date() | ||
|
||
# Calculate age | ||
age_years = now.year - birthday.year | ||
age_months = now.month - birthday.month | ||
age_days = now.day - birthday.day | ||
|
||
if(age_days < 0): | ||
age_months -= 1 | ||
|
||
'''1. If the age_days is negative, it implies the month must be one less than the month number that is calculated and stored in age_months | ||
2. "(now.month-1)%12 or 12" ensures that when the previous month is calculated, its value lie in the range [1, 12] | ||
''' | ||
previous_month = (now.month - 1) % 12 or 12 | ||
|
||
days_in_prev_month = (datetime.date(now.year, previous_month + 1, 1) - datetime.date(now.year, previous_month, 1)).days | ||
|
||
age_days += days_in_prev_month | ||
|
||
if (age_months < 0): | ||
'''If age_months is negative, it implies the year must be one less than the year number that is calculated and store in age_years''' | ||
age_years -= 1 | ||
age_months += 12 | ||
|
||
# Printing the current age of the user | ||
print(f"Your birthday is {birthday.strftime('%d %B %Y')}\nYour current age is {age_years} years, {age_months} months and {age_days} days.") | ||
|
||
except ValueError: | ||
print("Either the date or the format is invalid.") |
Oops, something went wrong.