-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce9d4ce
commit c290b3b
Showing
1 changed file
with
1 addition
and
0 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 @@ | ||
# Persian months months = ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"] # Helper function to check if a year is a leap year in the Persian calendar def is_persian_leap_year(year): leaps = [1, 5, 9, 13, 17, 22, 26, 30] return (year % 33) in leaps # Helper function to calculate the next Persian date def next_persian_date(year, month, day): """Get the next Persian date.""" day += 1 if (month <= 6 and day > 31) or (month > 6 and month < 12 and day > 30): day = 1 month += 1 elif month == 12: if (is_persian_leap_year(year) and day > 30) or (not is_persian_leap_year(year) and day > 29): day = 1 month = 1 year += 1 return year, month, day # Function to convert English digits to Persian digits def to_persian_digits(number): english_to_persian = str.maketrans("0123456789", "۰۱۲۳۴۵۶۷۸۹") return str(number).translate(english_to_persian) # Start and end dates start_year, start_month, start_day = 1357, 11, 22 end_year, end_month, end_day = 1403, 4, 22 # Generate dates current_year, current_month, current_day = start_year, start_month, start_day dates = [] while (current_year < end_year) or (current_year == end_year and current_month < end_month) or (current_year == end_year and current_month == end_month and current_day <= end_day): date_str = f"{to_persian_digits(current_day)}/{months[current_month-1]}/{to_persian_digits(current_year)}" dates.append(date_str) current_year, current_month, current_day = next_persian_date(current_year, current_month, current_day) # Join dates with ' - ' result = ' - '.join(dates) print(result) # Persian months months = ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"] # Helper function to check if a year is a leap year in the Persian calendar def is_persian_leap_year(year): leaps = [1, 5, 9, 13, 17, 22, 26, 30] return (year % 33) in leaps # Helper function to calculate the next Persian date def next_persian_date(year, month, day): """Get the next Persian date.""" day += 1 if (month <= 6 and day > 31) or (month > 6 and month < 12 and day > 30): day = 1 month += 1 elif month == 12: if (is_persian_leap_year(year) and day > 30) or (not is_persian_leap_year(year) and day > 29): day = 1 month = 1 year += 1 return year, month, day # Start and end dates start_year, start_month, start_day = 1357, 11, 22 end_year, end_month, end_day = 1403, 4, 22 # Generate dates current_year, current_month, current_day = start_year, start_month, start_day dates = [] while (current_year < end_year) or (current_year == end_year and current_month < end_month) or (current_year == end_year and current_month == end_month and current_day <= end_day): date_str = f"{current_day}/{months[current_month-1]}/{current_year}" dates.append(date_str) current_year, current_month, current_day = next_persian_date(current_year, current_month, current_day) # Join dates with ' - ' result = ' - '.join(dates) print(result) |