Professional Documents
Culture Documents
for Nepali date conversion | Sharing Knowledge
Sharing Knowledge
BlogNirmal Raj Joshi
Announcement Algorithm for Nepali date conversion
no new announcement..
If you are looking for code to put in your website visit
http://nepalidateconve.sourceforge.net/ to download php code.
Search
…..i don’t have time to read..download NepaliDateConverterAddIn.xlsm now.
The codes
Menu
About Nepali date conversion consists of two parts
Contact
A. Data of number of days that occur in each month in each year. This is the
reason why all the Nepali date conversion programs have its limitations
Books
B. Algorithm to convert the date from AD to BS or vice versa.
Computer Science (11)
Autocad (1) This is explained with the code in VBA (in Excel) below with the required steps.
Engineering (25)
Design sheets (4) 1. Open MS Excel
Hydraulics (2)
2. Open Visual Basic editor (short cut Alt + F11)
Health and Sprituality (2)
Literature (8) 3. Insert a class module
Movie (2)
Mathematics (9) 4. Rename the class module to Nepali_Calender in Properties window (F4)
Music (10)
Uncategorized (5)
5. Paste the code 1 given at the end of this article
6. Insert a Module (normal module not class module!) and Paste the code 2 . It
External Links consists of two functions :
facebook 0 a. nepaliToEnglish(y,m,d,formateCode)
nirmaljoshi.com.np 0
b. englishToNepali(y,m,d,formateCode)
where y,m,d=year, month and day and formate code will display the desired output
format
Formate code Formate
0 20671/25
1 2067Mangsir25
Travel Blog
a story
Half baked 2 2067Mangsir25Saturday
(dreaming again :p)
7. Now close the editor
From siddhant
8. Save your file as *.xlsm (macro enabled)
9. Now you can use two functions made in step 6
10. To make these functions available to all the worksheets
a. save this sheet as addins *.xlam format
b. then enable it at Excel Options>Add in>Manage
c. the function will be available as user defined function under Insert functions
11. . In this code the limits are
a. AD 19442033
b. BS 20002089
c. if date is out of range then output is string “Out of range”
More Photos The readymade file is also available. Download NepaliDateConverterAddIn.xlsm
now.
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 1/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
If you are looking for code to put in your website visit
http://nepalidateconve.sourceforge.net/ to download php code.
In my mind
Code1
.np domain AD to BS Algorithm Ana
Angle Autocad bhailo biorhythm BS to Option Explicit
AD building Centroid of trapezoidal ‘the original sorce code of this program is found in sourceforge.net
chord chords
Channel
‘the code in php was translated to VBA
code NBC Combined
Angle concrete Crack Dam ‘this addin is copyfree and can be distributed freely in multiple copies
delete dheusi Dhur dialogues
‘the user should be responsible for the use of this add in
download drivers earthquake
earthquake resistance ebook ‘the author is not liable for any damage that may occur by using this addin
Engineering Excel Ghunsa ‘modification to the code is welcome. Any additional data in the code if notified over
guidelines hide text Indian standard the internet will be usefull to all
invisible text IS I section jagdish hamal
‘***********************************************************************************************************
Kattha limca ad Lyrics
masonary masonry materials ‘*******currently can only calculate the date between BS 20002089 and AD 1944
2033*************************
Microhydro Monte carlos stimulation
Most efficient trapezoidal section of ‘***********************************************************************************************************
canal movie nepal Nepali ‘Coder: Nirmal Raj Joshi
date nepali song Nepal land
measurement nepal seismic Paisa
‘@copyfree nirmaljoshi.com.np,2010
Password PI Pipe Remove Password ‘joshi.amn@gmail.com
Ropani safety sano sansar steel Steel
table Stephen Hawking tapoban The Private bs As Variant
Elusive Theory of Everything tihar Public nep_date As Dictionary
timber top 10 of 2010 Tube vailo vba
width by height ratio wind windows xp Public eng_date As Dictionary
Public debug_info
Admin
Sub initilizeClass()
Register
Log in ReDim bs(90)
Entries RSS
bs(0) = Array(2000, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
Comments RSS
WordPress.com bs(1) = Array(2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(2) = Array(2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
RSS
bs(3) = Array(2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
RSS Posts
bs(4) = Array(2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
Blog Stats bs(5) = Array(2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
97,597 hits bs(6) = Array(2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(7) = Array(2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(8) = Array(2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31)
bs(9) = Array(2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(10) = Array(2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(11) = Array(2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(12) = Array(2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30)
bs(13) = Array(2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(14) = Array(2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(15) = Array(2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(16) = Array(2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30)
bs(17) = Array(2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(18) = Array(2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(19) = Array(2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(20) = Array(2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 2/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
bs(21) = Array(2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(22) = Array(2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30)
bs(23) = Array(2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(24) = Array(2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
bs(25) = Array(2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(26) = Array(2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(27) = Array(2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(28) = Array(2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(29) = Array(2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30)
bs(30) = Array(2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(31) = Array(2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(32) = Array(2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(33) = Array(2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(34) = Array(2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(35) = Array(2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31)
bs(36) = Array(2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(37) = Array(2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(38) = Array(2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(39) = Array(2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30)
bs(40) = Array(2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(41) = Array(2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(42) = Array(2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(43) = Array(2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30)
bs(44) = Array(2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(45) = Array(2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(46) = Array(2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(47) = Array(2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
bs(48) = Array(2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(49) = Array(2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30)
bs(50) = Array(2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(51) = Array(2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
bs(52) = Array(2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(53) = Array(2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30)
bs(54) = Array(2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(55) = Array(2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(56) = Array(2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30)
bs(57) = Array(2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(58) = Array(2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(59) = Array(2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(60) = Array(2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(61) = Array(2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(62) = Array(2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31)
September 2010
bs(63) = Array(2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
S M T W T F S
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 3/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
1 2 3 4
bs(64) = Array(2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
5 6 7 8 9 10 11 bs(65) = Array(2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
12 13 14 15 16 17 18 bs(66) = Array(2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31)
19 20 21 22 23 24 25 bs(67) = Array(2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
26 27 28 29 30 bs(68) = Array(2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(70) = Array(2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30)
bs(71) = Array(2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(72) = Array(2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30)
bs(73) = Array(2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31)
bs(74) = Array(2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
bs(75) = Array(2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(76) = Array(2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30)
bs(77) = Array(2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31)
bs(78) = Array(2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30)
bs(79) = Array(2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30)
bs(80) = Array(2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30)
bs(81) = Array(2081, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30)
bs(82) = Array(2082, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30)
bs(83) = Array(2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30)
bs(84) = Array(2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30)
bs(85) = Array(2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30)
bs(86) = Array(2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30)
bs(87) = Array(2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30)
bs(88) = Array(2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30)
bs(89) = Array(2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30)
bs(90) = Array(2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30)
Set nep_date = New Dictionary
nep_date.Add “year”, 0
nep_date.Add “month”, 0
nep_date.Add “date”, 0
nep_date.Add “day”, 0
nep_date.Add “nmonth”, 0
nep_date.Add “num_day”, 0
Set eng_date = New Dictionary
eng_date.Add “year”, 0
eng_date.Add “month”, 0
eng_date.Add “date”, 0
eng_date.Add “day”, 0
eng_date.Add “emonth”, 0
eng_date.Add “num_day”, 0
End Sub
‘ /**
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 4/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
‘ * Calculates wheather english year is leap year or not
‘ *
‘ * @param integer $year
‘ * @return boolean
‘ */’
Public Function is_leap_year(year) As Boolean
Dim a, returnVal
a = year
If a Mod 100 = 0 Then
If a Mod 400 = 0 Then
returnVal = True
Else
returnVal = False
End If
Else
If a Mod 4 = 0 Then
returnVal = True
Else
returnVal = False
End If
End If
is_leap_year = returnVal
End Function
Public Function get_nepali_month(m)
Dim n_month
n_month = False
Select Case m
Case 1:
n_month = “Baishak”
Case 2:
n_month = “Jestha”
Case 3:
n_month = “Ashad”
Case 4:
n_month = “Shrawn”
Case 5:
n_month = “Bhadra”
Case 6:
n_month = “Ashwin”
Case 7:
n_month = “Kartik”
Case 8:
n_month = “Mangshir”
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 5/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
Case 9:
n_month = “Poush”
Case 10:
n_month = “Magh”
Case 11:
n_month = “Falgun”
Case 12:
n_month = “Chaitra”
End Select
get_nepali_month = n_month
End Function
Public Function get_english_month(m)
Dim eMonth
eMonth = False
Select Case m
Case 1
eMonth = “January”
Case 2:
eMonth = “February”
Case 3:
eMonth = “March”
Case 4:
eMonth = “April”
Case 5:
eMonth = “May”
Case 6:
eMonth = “June”
Case 7:
eMonth = “July”
Case 8:
eMonth = “August”
Case 9:
eMonth = “September”
Case 10:
eMonth = “October”
Case 11:
eMonth = “November”
Case 12:
eMonth = “December”
End Select
get_english_month = eMonth
End Function
Public Function get_day_of_week(d)
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 6/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
Dim day
day = False
Select Case d
Case 1:
day = “Sunday”
Case 2:
day = “Monday”
Case 3:
day = “Tuesday”
Case 4:
day = “Wednesday”
Case 5:
day = “Thursday”
Case 6:
day = “Friday”
Case 7:
day = “Saturday”
End Select
get_day_of_week = day
End Function
Public Function is_range_eng(yy, mm, dd)
Dim returnVal
returnVal = True
If (yy < 1944 Or yy > 2033) Then
debug_info = “Supported only between 19442022”
returnVal = False
End If
If (mm < 1 Or mm > 12) Then
debug_info = “Error! value 112 only”
returnVal = False
End If
If (dd < 1 Or dd > 31) Then
debug_info = “Error! value 131 only”
returnVal = False
End If
is_range_eng = returnVal
End Function
Public Function is_range_nep(yy, mm, dd)
Dim returnVal
returnVal = True
If (yy < 2000 Or yy > 2089) Then
debug_info = “Supported only between 20002089”
returnVal = False
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 7/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
End If
If (mm < 1 Or mm > 12) Then
debug_info = “Error! value 112 only”
returnVal = False
End If
If (dd < 1 Or dd > 32) Then
debug_info = “Error! value 131 only”
returnVal = False
End If
is_range_nep = returnVal
End Function
‘ /**
‘ * currently can only calculate the date between AD 19442033…
‘ *
‘ * @param unknown_type $yy
‘ * @param unknown_type $mm
‘ * @param unknown_type $dd
‘ * @return unknown
‘ */
Public Sub eng_to_nep(yy, mm, dd)
If (is_range_eng(yy, mm, dd) = False) Then
debug_info = “Out of range”
Else
‘ // english month data.
Dim month, lmonth
month = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
lmonth = Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
Dim def_eyy, def_nyy, def_nmm, def_ndd
Dim total_eDays, total_nDays, a, day
Dim m, y, i, j
Dim numDay
def_eyy = 1944 ‘ //spear head english date…
def_nyy = 2000: def_nmm = 9: def_ndd = 17 – 1 ‘ //spear head nepali date…
total_eDays = 0: total_nDays = 0: a = 0: day = 7 – 1 ‘ //all the initializations…
m = 0: y = 0: i = 0: j = 0
numDay = 0
‘// count total no. of days interms of year
For i = 0 To yy – def_eyy – 1 ‘ //total days for month calculation…(english)
If (is_leap_year(def_eyy + i) = True) Then
For j = 0 To 12 – 1
total_eDays = total_eDays + lmonth(j)
Next j
Else
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 8/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
For j = 0 To 12 – 1
total_eDays = total_eDays + month(j)
Next j
End If
Next i
‘// count total no. of days interms of month
For i = 0 To (mm – 1) – 1
If (is_leap_year(yy) = True) Then
total_eDays = total_eDays + lmonth(i)
Else
total_eDays = total_eDays + month(i)
End If
Next i
‘ // count total no. of days interms of date
total_eDays = total_eDays + dd
i = 0: j = def_nmm
total_nDays = def_ndd
m = def_nmm
y = def_nyy
‘// count nepali date from array
Do While (total_eDays <> 0)
a = bs(i)(j)
total_nDays = total_nDays + 1 ‘ //count the days
day = day + 1 ‘ //count the days interms of 7 days
If (total_nDays > a) Then
m = m + 1
total_nDays = 1
j = j + 1
End If
If (day > 7) Then
day = 1
End If
If (m > 12) Then
y = y + 1
m = 1
End If
If (j > 12) Then
j = 1: i = i + 1
End If
total_eDays = total_eDays – 1
Loop
numDay = day
nep_date(“year”) = y
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 9/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
nep_date(“month”) = m
nep_date(“date”) = total_nDays
nep_date(“day”) = get_day_of_week(day)
nep_date(“nmonth”) = get_nepali_month(m)
nep_date(“num_day”) = numDay
End If
End Sub
‘ /**
‘ * currently can only calculate the date between BS 20002089
‘ *
‘ * @param unknown_type $yy
‘ * @param unknown_type $mm
‘ * @param unknown_type $dd
‘ * @return unknown
‘ */
Public Sub nep_to_eng(yy, mm, dd)
Dim def_eyy, def_emm, def_edd
Dim def_nyy, def_nmm, def_ndd
Dim total_eDays, total_nDays, a, day
Dim m, y, i, j
Dim k, numDay
Dim month, lmonth
def_eyy = 1943: def_emm = 4: def_edd = 14 – 1 ‘// init english date.
def_nyy = 2000: def_nmm = 1: def_ndd = 1 ‘ // equivalent nepali date.
total_eDays = 0: total_nDays = 0: a = 0: day = 4 – 1 ‘ // initializations…
m = 0: y = 0: i = 0
k = 0: numDay = 0
month = Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
lmonth = Array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
If (is_range_nep(yy, mm, dd) = False) Then
debug_info = “Out of range”
Else
‘// count total days interms of year
For i = 0 To yy – def_nyy – 1
For j = 1 To 12
total_nDays = total_nDays + bs(k)(j)
Next j
k = k + 1
Next i
‘// count total days interms of month
For j = 1 To mm – 1
total_nDays = total_nDays + bs(k)(j)
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 10/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
Next j
‘// count total days interms of dat
total_nDays = total_nDays + dd
‘//calculation of equivalent english date…
total_eDays = def_edd
m = def_emm
y = def_eyy
Do While (total_nDays <> 0)
If (is_leap_year(y)) Then
a = lmonth(m)
Else
a = month(m)
End If
total_eDays = total_eDays + 1
day = day + 1
If (total_eDays > a) Then
m = m + 1
total_eDays = 1
If (m > 12) Then
y = y + 1
m = 1
End If
End If
If (day > 7) Then day = 1
total_nDays = total_nDays – 1
Loop
numDay = day
eng_date(“year”) = y
eng_date(“month”) = m
eng_date(“date”) = total_eDays
eng_date(“day”) = get_day_of_week(day)
eng_date(“emonth”) = get_english_month(m)
eng_date(“num_day”) = numDay
End If
End Sub
Code 2
Public Function nepaliToEnglish(yy, mm, dd, formate)
‘ this function depends on Nepali_calander class
‘@copyfree nirmaljoshi.com.np,2010
‘formateType default=2010/1/25
‘formateType 1=2010jan25
‘formateType 2=2010jan25saturday
If IsMissing(formate) Then formateType = 0
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 11/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
‘MsgBox formateType
Dim a As Nepali_Calender
Set a = New Nepali_Calender
Call a.initilizeClass
Call a.nep_to_eng(yy, mm, dd)
If a.debug_info = “” Then
Select Case formate
Case 1:
output = a.eng_date(“year”) & “” & a.eng_date(“emonth”) & “” &
a.eng_date(“date”)
Case 2:
output = a.eng_date(“year”) & “” & a.eng_date(“emonth”) & “” &
a.eng_date(“date”) & “” & a.eng_date(“day”)
Case Else:
output = a.eng_date(“year”) & “/” & a.eng_date(“month”) & “/” & a.eng_date(“date”)
End Select
Else
output = a.debug_info
End If
nepaliToEnglish = output
End Function
Public Function englishToNepali(yy, mm, dd, formate)
‘ this function depends on Nepali_calander class
‘@copyfree nirmaljoshi.com.np,2010
‘formateType default=20671/25
‘formateType 1=2067mangsir25
‘formateType 2=2067mangsir25saturday
If IsMissing(formate) Then formateType = 0
‘MsgBox formateType
Dim a As Nepali_Calender
Set a = New Nepali_Calender
Call a.initilizeClass
Call a.eng_to_nep(yy, mm, dd)
If a.debug_info = “” Then
Select Case formate
Case 1:
output = a.nep_date(“year”) & “” & a.nep_date(“nmonth”) & “” &
a.nep_date(“date”)
Case 2:
output = a.nep_date(“year”) & “” & a.nep_date(“nmonth”) & “” &
a.nep_date(“date”) & “” & a.nep_date(“day”)
Case Else:
output = a.nep_date(“year”) & “/” & a.nep_date(“month”) & “/” & a.nep_date(“date”)
End Select
Else
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 12/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
output = a.debug_info
End If
englishToNepali = output
End Function
Advertisements
Like
Be the first to like this.
Related
By nirmaljoshi, on September 12, 2010 at 10:27 am, under Computer Science. Tags: AD to BS,
Algorithm, BS to AD, Nepali date. 47 Comments
Post a comment or leave a trackback: Trackback URL.
« The Absurd Autocad The Elusive Theory of Everything »
Comments
Binay Ligal On November 12, 2010 at 12:56 pm Permalink | Reply
Nice work there. I’ve been looking for something like this for a long time. Quite an
effort you’ve put there.
Kudos to you my friend.
Binay
nirmaljoshi On November 13, 2010 at 1:41 pm Permalink | Reply
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 13/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
thanks man..
s2c On November 24, 2010 at 9:16 am Permalink | Reply
can we use this code in ms access or sql?if yes how? hope you will help me?
thanx in adv.
nirmaljoshi On November 25, 2010 at 11:33 am Permalink | Reply
Yes, this can be done.The syntax of the doing this depends upon the type of
programming language you’ll use like ‘php’ or ‘vb’ or ‘c’ etc. I hope you will learn
yourself to implement this as per your requirements. If you require further
assistance please put a message.
s2c On November 25, 2010 at 11:40 am Permalink | Reply
thank you for ur reply
nirmaljoshi On November 27, 2010 at 9:36 pm Permalink | Reply
welcome!
Kushal Kathayat On January 1, 2011 at 5:51 pm Permalink | Reply
I tried this code, it works well in excel but when i tried this code in vb 6.0 an error
occured saying “User defined type not defined” for the code:
Public nep_date As Dictionary
Public eng_date As Dictionary
Is there any way to resolve this problem? I tried a lot but cant solve this problem.
nirmaljoshi On January 3, 2011 at 12:42 pm Permalink | Reply
The dictinary class of VBA of excel is similar to associative array. I am not sure
if VB6 has this feature or not. But other language like php and java etc has
this feature. In the associative array we can recall the value by using the key.
The key is string and is similar to index of an array. Following example will
illustrate it. And by the way you can use just a siple array as well.
Associatve array:
A("Key")=value
If there is no feature of this then you can use
A(1)=value
and just follow the index to take out our value.
The code in excel is
Set eng_date = New Dictionary
eng_date.Add "year", 0
eng_date.Add "month", 0
eng_date.Add "date", 0
eng_date.Add "day", 0
eng_date.Add "emonth", 0
eng_date.Add "num_day", 0
it should look like following if there is associative array.
dim eng_date(4)
eng_date("year")= 0
eng_date("month")= 0
eng_date("date")= 0
eng_date("day")= 0
eng_date("emonth")= 0
eng_date("num_day")= 0
Or just use
dim eng_date(4)
eng_date(0)= 0
eng_date(1)= 0
eng_date(2)= 0
eng_date(3)= 0
eng_date(4)= 0
eng_date(5)= 0
where 0=year,1=month etc..
in excel there is no such delaration possible hence we had to use
DICTIONARY class.
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 14/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
Hope this will help you.
Cheers!
shaswat On February 3, 2011 at 1:56 pm Permalink | Reply
thanx man… i was having problem in getting the total days difference between ad
and bs…. bt studing ur algorithm i got the logic…. thanx again….
Rajan Shrestha On April 4, 2011 at 3:17 pm Permalink | Reply
Nice post…It was really helpful
nirmaljoshi On April 5, 2011 at 8:19 pm Permalink | Reply
thank you.
jitendra On April 20, 2011 at 11:18 pm Permalink | Reply
Thanks Man, Sounds great… i get the logic and will try to create API… hope it will
work.
SKC On June 6, 2011 at 7:48 pm Permalink | Reply
Hi Nirmal Ji
I followed exactly same as you said I typed following in excel cell.
=englishToNepali(2011,6,6,0)
but it displays error message
————
Compile Error
User definedtype not defined
————
error is displaying in the line
Public nep_date As Dictionary
in Nepali_Calender Class module
Could you please write me back.
thank you.
SKC
nirmaljoshi On June 8, 2011 at 4:07 pm Permalink | Reply
Hi, SKC,
Probably you didnt enable the macros in the excel sheet. Or more likely, you
copied and pasted the macros in normal “module” only but forgot to copy the
macro in “class module”.
You try the excel sheet as linked in the same page. URL to download the file is:
http://www.fileden.com/files/2010/9/12/2967753/SharingKnowledgeBlog/NepaliDateConverterAddIn.
Please see the macros in this file. If u have further queries tell me.
mILAN On September 20, 2011 at 12:43 pm Permalink | Reply
Thanks for your effort. This is exactly what I’ve been looking for.
surendra shrestha On December 1, 2011 at 3:57 pm Permalink | Reply
how can we use this code in ms access or sql?
Devanagari Fonts On January 17, 2012 at 12:38 pm Permalink | Reply
Thanks for the code. I was looking for it.
pythonepal On February 25, 2012 at 7:27 pm Permalink | Reply
could you post an algorithm or at least a formula for the conversion. I am not good
at either of the above languages. Or it will be much better if you posted a python
version of functions eng_to_nep() and nep_to_eng() if you know python.
nirmaljoshi On March 1, 2012 at 5:50 pm Permalink | Reply
i know only one python.. and this reptile is very poisionous… hope you will
crack the codes yourself.
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 15/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
pythonepal On April 2, 2012 at 4:28 pm Permalink
I’m half way there. And yes, pythons are not poisonous. Its a
helpful post by the way
pass@port On February 29, 2012 at 11:44 pm Permalink | Reply
Thanx a lot…
Skashusen On July 27, 2012 at 2:59 pm Permalink | Reply
nice work
aviral abijeet On October 28, 2012 at 3:09 pm Permalink | Reply
can anyone provide php version
nirmaljoshi On October 28, 2012 at 3:39 pm Permalink | Reply
http://nepalidateconve.sourceforge.net/
Raman Stha On December 9, 2012 at 7:34 pm Permalink | Reply
Can I get a C code for this program?
sarojraut2001oj raut On January 15, 2013 at 6:54 pm Permalink | Reply
can i get vb.net code
chhabi koirala On August 3, 2013 at 7:56 am Permalink | Reply
sir I want this code on vb6.or I want ocx activeX control for convert AD to
BS.please help me
Corin On May 10, 2014 at 4:37 pm Permalink | Reply
This works in Excel Vba – however Access Vba does not support Dictionaries :(.
I will have to rewrite for Access.
Nicely selfannotated code :).
Anyone have the code for Access?
Corin On May 27, 2014 at 1:58 am Permalink | Reply
a day and a half + some thinking and it works in VBa for Access. Nice work and
Thanks
Devendra Kumar Rai (@rai_devendra) On July 18, 2014 at 2:47 pm Permalink | Reply
Thank you for the code. I want to get Month or Day only like
englishToNepali(MONTH(TODAY())) OR englishToNepali(DAY(TODAY()))
Saugat Gautam On December 22, 2014 at 3:20 pm Permalink | Reply
thanks for code, but can some one provide me code for VBA Access plz, a am
unble to convert
pradeeep On December 23, 2014 at 12:29 pm Permalink | Reply
Dear Nirloj sir,
i tried in excel for nepali to english date convert it’s work for one only i need 2 or
more cell convert in one click is it possible or not? if possible can you please teach
me about formula for my problem. i have to changed 1000 and more cell with one
formula.
please help me…….!!!!
Shrijan Shrestha On March 31, 2015 at 10:34 am Permalink | Reply
Can we use this to change the date to bs in the post date in wordpress??
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 16/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
nirmaljoshi On April 28, 2015 at 12:31 pm Permalink | Reply
If there is compile time
error saying ‘user type not defined’, in VBA editor goto Tools>Reference and
check Microsoft Scripting Runtime.
rajan shrestha On May 22, 2015 at 9:48 am Permalink | Reply
problem not solved. please can someone provide the excel file
nirmaljoshi On August 19, 2015 at 1:26 pm Permalink | Reply
Please download the excel file and see the codes. I have updated the link to
file which was dead due to shift in google drive.
Sa Baid On August 19, 2015 at 12:54 pm Permalink | Reply
Hi Nirmal Sir. I have tried the code but it shows value error. I had put code 1 in
class module and code 2 in normal module. Please help me for the solution of
problem
nirmaljoshi On August 19, 2015 at 1:24 pm Permalink | Reply
Please download the excel file and see the codes. I have updated the link to
file which was dead due to shift in google drive.
hghuuhjnhjk On October 27, 2015 at 8:31 pm Permalink | Reply
i was hoping for an real algo, this info can be easily collected thru many medias.
Homer Shrestha On October 20, 2016 at 7:08 am Permalink | Reply
There are bugs. It shouldn’t have converted 2073/10/30 & 2073/9/30. But it does.
Please check
nirmaljoshi On October 20, 2016 at 9:36 am Permalink | Reply
what is the issue? I think its working fine.
Homer Stha On October 20, 2016 at 10:36 am Permalink
There are no dates 2073/10/30 and 9/30 but it is showing it as 2/12 and
1/14
nirmaljoshi On October 20, 2016 at 11:02 am Permalink | Reply
Yes you are correct. The input should be checked before entering. GIGO…
Homer Stha On October 20, 2016 at 10:38 am Permalink | Reply
9/29/2073 2017January13Friday
9/30/2073 2017January14Saturday
There is no 9/30
Homer Stha On October 20, 2016 at 12:22 pm Permalink | Reply
Can you put some validation in your code so that it checks in the case statement if
that particular month has no more days than prescribed.
nirmaljoshi On October 20, 2016 at 12:35 pm Permalink | Reply
good suggestion. Will update in next version. Thanks.
Homer Stha On October 20, 2016 at 5:11 pm Permalink
I’m hoping that you update it at the earliest. I have been using your addins
and now stuck there.
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 17/18
6/18/2017 Algorithm for Nepali date conversion | Sharing Knowledge
Leave a Reply
Enter your comment here...
Create a free website or blog at WordPress.com. | .
https://nirmaljoshi.wordpress.com/2010/09/12/algorithmfornepalidateconversion/ 18/18