-
Notifications
You must be signed in to change notification settings - Fork 2
/
Eng2Nep.py
169 lines (145 loc) · 7.01 KB
/
Eng2Nep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from datetime import date
import datetime
import time
import calendar
# Below is a List of no. of days in each month of each year within a valid range.
# where, 2000, 2001, 2002 and so on are the Nepali years and 30, 32, 31 and so on are the total days in months
# Nepali year-month List
nepaliMonths = [
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ], #2000
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ], #2001
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],
[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ], #2071
[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ], #2072
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ], #2073
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],
[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],
[ 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30 ],
[ 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ], #2090
[ 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30 ],
[ 30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30 ],
[ 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],
[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],
[ 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31 ],
[ 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30 ] #2099
]
engMonth, engDate, engYear = map(int, input("Enter English Month, Date and Year seperated by space: ").split())
#Define the least possible English date 1944/01/01 Saturday.
startingEngYear = 1944
startingEngMonth = 1
startingEngDay = 1
dayOfWeek = calendar.SATURDAY
#Let's define the equivalent Nepali date 2000/09/17.
startingNepYear = 2000
startingNepMonth = 9
startingNepday = 17
# Let's calculate the number of days between the two English dates as follows:
date0=date(engYear,engMonth,engDate)
date1=date(startingEngYear,startingEngMonth,startingEngDay)
diff=(date0 - date1).days
#Initialize required nepali date variables with starting nepali date
nepYear = startingNepYear
nepMonth = startingNepMonth
nepDay = startingNepday
#Decreament delta.days until its value becomes zero.
while diff != 0:
# Getting total number of days in month nepMonth in a year nepYear
daysInMonth = nepaliMonths[nepYear - 2000][nepMonth - 1]
nepDay+=1 # incrementing nepali day
if(nepDay > daysInMonth):
nepMonth+=1
nepDay = 1
if(nepMonth > 12):
nepYear+=1
nepMonth = 1
dayOfWeek+=1
#counting the days in terms of 7 days
if(dayOfWeek > 7):
dayOfWeek = 1
diff-=1
# finally we print the converted date
print("Your equivalent Nepali date is: %s,%s,%s " %(nepYear, nepMonth, nepDay))