Changeset 3103095
- Timestamp:
- 06/15/2024 12:53:37 PM (22 months ago)
- Location:
- nepali-date-converter
- Files:
-
- 27 added
- 3 edited
-
tags/2.0.7 (added)
-
tags/2.0.7/LICENSE (added)
-
tags/2.0.7/inc (added)
-
tags/2.0.7/inc/class (added)
-
tags/2.0.7/inc/class/ndc-frontend.php (added)
-
tags/2.0.7/inc/class/ndc-post-date.php (added)
-
tags/2.0.7/inc/frameworks (added)
-
tags/2.0.7/inc/frameworks/nepali-calendar (added)
-
tags/2.0.7/inc/frameworks/nepali-calendar/nepali_calendar.php (added)
-
tags/2.0.7/inc/functions (added)
-
tags/2.0.7/inc/functions/functions.php (added)
-
tags/2.0.7/inc/hooks (added)
-
tags/2.0.7/inc/hooks/enqueue-scripts.php (added)
-
tags/2.0.7/inc/hooks/wp-ajax.php (added)
-
tags/2.0.7/inc/hooks/wp-footer.php (added)
-
tags/2.0.7/inc/init.php (added)
-
tags/2.0.7/inc/shortcode (added)
-
tags/2.0.7/inc/shortcode/shortcode-nepali-date-converter.php (added)
-
tags/2.0.7/inc/shortcode/shortcode-today-date.php (added)
-
tags/2.0.7/inc/widgets (added)
-
tags/2.0.7/inc/widgets/widget-nepali-date-converter.php (added)
-
tags/2.0.7/inc/widgets/widget-today-date.php (added)
-
tags/2.0.7/index.php (added)
-
tags/2.0.7/languages (added)
-
tags/2.0.7/languages/index.php (added)
-
tags/2.0.7/nepali-date-converter.php (added)
-
tags/2.0.7/readme.txt (added)
-
trunk/inc/frameworks/nepali-calendar/nepali_calendar.php (modified) (30 diffs)
-
trunk/nepali-date-converter.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nepali-date-converter/trunk/inc/frameworks/nepali-calendar/nepali_calendar.php
r2322536 r3103095 8 8 9 9 Day of Month 10 d Numeric, with leading zeros01–3111 j Numeric, without leading zeros1–3112 S The English suffix for the day of the monthst, nd or th in the 1st, 2nd or 15th.//This is not supported10 d Numeric, with leading zeros 01–31 11 j Numeric, without leading zeros 1–31 12 S The English suffix for the day of the month st, nd or th in the 1st, 2nd or 15th.//This is not supported 13 13 14 14 Weekday 15 l Full name (lowercase 'L')Sunday – Saturday16 D Three letter nameMon – Sun15 l Full name (lowercase 'L') Sunday – Saturday 16 D Three letter name Mon – Sun 17 17 18 18 Month 19 m Numeric, with leading zeros01–1220 n Numeric, without leading zeros1–1221 F Textual fullJanuary – December22 M Textual three lettersJan - Dec19 m Numeric, with leading zeros 01–12 20 n Numeric, without leading zeros 1–12 21 F Textual full January – December 22 M Textual three letters Jan - Dec 23 23 24 24 Year 25 Y Numeric, 4 digitsEg., 1999, 200326 y Numeric, 2 digitsEg., 99, 0325 Y Numeric, 4 digits Eg., 1999, 2003 26 y Numeric, 2 digits Eg., 99, 03 27 27 28 28 */ 29 29 30 if ( ! class_exists( 'NDC_Nepali_Calendar' ) ) {30 if ( ! class_exists( 'NDC_Nepali_Calendar' ) ) { 31 31 class NDC_Nepali_Calendar { 32 32 /*added*/ … … 37 37 * @access public 38 38 * @since 1.0 39 * 40 */ 41 public $eng_nep_num = array( 42 '0'=>'०', 43 '1'=>'१', 44 '2'=>'२', 45 '3'=>'३', 46 '4'=>'४', 47 '5'=>'५', 48 '6'=>'६', 49 '7'=>'७', 50 '8'=>'८', 51 '9'=>'९' 39 */ 40 public $eng_nep_num = array( 41 '0' => '०', 42 '1' => '१', 43 '2' => '२', 44 '3' => '३', 45 '4' => '४', 46 '5' => '५', 47 '6' => '६', 48 '7' => '७', 49 '8' => '८', 50 '9' => '९', 52 51 ); 53 52 … … 58 57 * @access public 59 58 * @since 1.0 60 *61 59 */ 62 60 public $long_eng_nep_mth = array( 63 "January"=> 'बैशाख',64 "February"=> 'जेष्ठ',65 "March"=> 'असार',66 "April"=> 'साउन',67 "May"=> 'भदौ',68 "June"=> 'अशोज',69 "July"=> 'कार्तिक',70 "August"=> 'मंसिर',71 "September"=> 'पुस',72 "October"=> 'माघ',73 "November"=> 'फाल्गुन',74 "December"=> 'चैत्र'61 'January' => 'बैशाख', 62 'February' => 'जेष्ठ', 63 'March' => 'असार', 64 'April' => 'साउन', 65 'May' => 'भदौ', 66 'June' => 'अशोज', 67 'July' => 'कार्तिक', 68 'August' => 'मंसिर', 69 'September' => 'पुस', 70 'October' => 'माघ', 71 'November' => 'फाल्गुन', 72 'December' => 'चैत्र', 75 73 ); 76 74 … … 81 79 * @access public 82 80 * @since 1.0 83 *84 81 */ 85 82 public $long_eng_nep_mth_in_eng = array( 86 "January"=> 'Baishakh',87 "February"=> 'Jestha',88 "March"=> 'Ashad',89 "April"=> 'Shrawan',90 "May"=> 'Bhadra',91 "June"=> 'Ashwin',92 "July"=> 'Kartik',93 "August"=> 'Mangshir',94 "September"=> 'Poush',95 "October"=> 'Magh',96 "November"=> 'Falgun',97 "December"=> 'Chaitra'83 'January' => 'Baishakh', 84 'February' => 'Jestha', 85 'March' => 'Ashad', 86 'April' => 'Shrawan', 87 'May' => 'Bhadra', 88 'June' => 'Ashwin', 89 'July' => 'Kartik', 90 'August' => 'Mangshir', 91 'September' => 'Poush', 92 'October' => 'Magh', 93 'November' => 'Falgun', 94 'December' => 'Chaitra', 98 95 ); 99 96 … … 104 101 * @access public 105 102 * @since 1.0 106 *107 103 */ 108 104 public $short_eng_nep_mth = array( 109 "Jan"=> 'बैशाख',110 "Feb"=> 'जेष्ठ',111 "Mar"=> 'असार',112 "Apr"=> 'साउन',113 "May"=> 'भदौ',114 "Jun"=> 'अशोज',115 "Jul"=> 'कार्तिक',116 "Aug"=> 'मंसिर',117 "Sep"=> 'पुस',118 "Oct"=> 'माघ',119 "Nov"=> 'फाल्गुन',120 "Dec" => 'चैत्र'105 'Jan' => 'बैशाख', 106 'Feb' => 'जेष्ठ', 107 'Mar' => 'असार', 108 'Apr' => 'साउन', 109 'May' => 'भदौ', 110 'Jun' => 'अशोज', 111 'Jul' => 'कार्तिक', 112 'Aug' => 'मंसिर', 113 'Sep' => 'पुस', 114 'Oct' => 'माघ', 115 'Nov' => 'फाल्गुन', 116 'Dec' => 'चैत्र', 121 117 ); 122 118 … … 127 123 * @access public 128 124 * @since 1.0 129 *130 125 */ 131 126 public $short_eng_nep_mth_in_eng = array( 132 "Jan"=> 'Baishakh',133 "Feb"=> 'Jestha',134 "Mar"=> 'Ashad',135 "Apr"=> 'Shrawan',136 "May"=> 'Bhadra',137 "Jun"=> 'Ashwin',138 "Jul"=> 'Kartik',139 "Aug"=> 'Mangshir',140 "Sep"=> 'Poush',141 "Oct"=> 'Magh',142 "Nov"=> 'Falgun',143 "Dec"=> 'Chaitra'127 'Jan' => 'Baishakh', 128 'Feb' => 'Jestha', 129 'Mar' => 'Ashad', 130 'Apr' => 'Shrawan', 131 'May' => 'Bhadra', 132 'Jun' => 'Ashwin', 133 'Jul' => 'Kartik', 134 'Aug' => 'Mangshir', 135 'Sep' => 'Poush', 136 'Oct' => 'Magh', 137 'Nov' => 'Falgun', 138 'Dec' => 'Chaitra', 144 139 ); 145 140 … … 150 145 * @access public 151 146 * @since 1.0 152 *153 147 */ 154 148 public $long_eng_nep_day = array( 155 "Sunday"=> 'आइतवार',156 "Monday"=> 'सोमवार',157 "Tuesday"=> 'मङ्लबार',158 "Wednesday"=> 'बुधबार',159 "Thursday"=> 'बिहिबार',160 "Friday"=> 'शुक्रबार',161 "Saturday"=> 'शनिबार'149 'Sunday' => 'आइतवार', 150 'Monday' => 'सोमवार', 151 'Tuesday' => 'मङ्लबार', 152 'Wednesday' => 'बुधबार', 153 'Thursday' => 'बिहिबार', 154 'Friday' => 'शुक्रबार', 155 'Saturday' => 'शनिबार', 162 156 ); 163 157 … … 168 162 * @access public 169 163 * @since 1.0 170 *171 164 */ 172 165 public $long_eng_nep_day_eng = array( 173 "Sunday"=> 'Aaitabar',174 "Monday"=> 'Sombar',175 "Tuesday"=> 'Mangalbar',176 "Wednesday"=> 'Budhabar',177 "Thursday"=> 'Bihibar',178 "Friday"=> 'Sukrabar',179 "Saturday"=> 'Sanibar'166 'Sunday' => 'Aaitabar', 167 'Monday' => 'Sombar', 168 'Tuesday' => 'Mangalbar', 169 'Wednesday' => 'Budhabar', 170 'Thursday' => 'Bihibar', 171 'Friday' => 'Sukrabar', 172 'Saturday' => 'Sanibar', 180 173 ); 181 174 … … 186 179 * @access public 187 180 * @since 1.0 188 *189 181 */ 190 182 public $short_eng_nep_day = array( 191 "Sun"=> 'आइत',192 "Mon"=> 'सोम',193 "Tue"=> 'मङ्ल',194 "Wed"=> 'बुध',195 "Thu"=> 'बिहि',196 "Fri"=> 'शुक्र',197 "Sat"=> 'शनि'183 'Sun' => 'आइत', 184 'Mon' => 'सोम', 185 'Tue' => 'मङ्ल', 186 'Wed' => 'बुध', 187 'Thu' => 'बिहि', 188 'Fri' => 'शुक्र', 189 'Sat' => 'शनि', 198 190 ); 199 191 … … 204 196 * @access public 205 197 * @since 1.0 206 *207 198 */ 208 199 public $short_eng_nep_day_eng = array( 209 "Sun"=> 'Aaita',210 "Mon"=> 'Som',211 "Tue"=> 'Mangal',212 "Wed"=> 'Budha',213 "Thu"=> 'Bihi',214 "Fri"=> 'Sukra',215 "Sat"=> 'Sani'200 'Sun' => 'Aaita', 201 'Mon' => 'Som', 202 'Tue' => 'Mangal', 203 'Wed' => 'Budha', 204 'Thu' => 'Bihi', 205 'Fri' => 'Sukra', 206 'Sat' => 'Sani', 216 207 ); 217 208 218 209 /*Some numeric functions for date format Start=====================*/ 219 private function getTwoCharStr( $str){220 if (strlen($str) == 0){210 private function getTwoCharStr( $str ) { 211 if ( strlen( $str ) == 0 ) { 221 212 return '00'; 222 213 } 223 if (strlen($str) == 1){224 return '0' .$str;225 } 226 return $str;214 if ( strlen( $str ) == 1 ) { 215 return '0' . $str; 216 } 217 return $str; 227 218 } 228 private function getNepMonthToNumeric( $str){229 if (strlen($str) == 0){219 private function getNepMonthToNumeric( $str ) { 220 if ( strlen( $str ) == 0 ) { 230 221 return '00'; 231 222 } 232 if (strlen($str) == 1){233 return '0' .$str;234 } 235 return $str;223 if ( strlen( $str ) == 1 ) { 224 return '0' . $str; 225 } 226 return $str; 236 227 } 237 228 /*Some numeric functions for date format End=====================*/ … … 246 237 * @access private 247 238 * @since 1.0 248 *249 239 */ 250 240 private $_c_bs = array( 251 0 => array(2000,30,32,31,32,31,30,30,30,29,30,29,31),252 1 => array(2001,31,31,32,31,31,31,30,29,30,29,30,30),253 2 => array(2002,31,31,32,32,31,30,30,29,30,29,30,30),254 3 => array(2003,31,32,31,32,31,30,30,30,29,29,30,31),255 4 => array(2004,30,32,31,32,31,30,30,30,29,30,29,31),256 5 => array(2005,31,31,32,31,31,31,30,29,30,29,30,30),257 6 => array(2006,31,31,32,32,31,30,30,29,30,29,30,30),258 7 => array(2007,31,32,31,32,31,30,30,30,29,29,30,31),259 8 => array(2008,31,31,31,32,31,31,29,30,30,29,29,31),260 9 => array(2009,31,31,32,31,31,31,30,29,30,29,30,30),261 10 => array( 2010,31,31,32,32,31,30,30,29,30,29,30,30),262 11 => array( 2011,31,32,31,32,31,30,30,30,29,29,30,31),263 12 => array( 2012,31,31,31,32,31,31,29,30,30,29,30,30),264 13 => array( 2013,31,31,32,31,31,31,30,29,30,29,30,30),265 14 => array( 2014,31,31,32,32,31,30,30,29,30,29,30,30),266 15 => array( 2015,31,32,31,32,31,30,30,30,29,29,30,31),267 16 => array( 2016,31,31,31,32,31,31,29,30,30,29,30,30),268 17 => array( 2017,31,31,32,31,31,31,30,29,30,29,30,30),269 18 => array( 2018,31,32,31,32,31,30,30,29,30,29,30,30),270 19 => array( 2019,31,32,31,32,31,30,30,30,29,30,29,31),271 20 => array( 2020,31,31,31,32,31,31,30,29,30,29,30,30),272 21 => array( 2021,31,31,32,31,31,31,30,29,30,29,30,30),273 22 => array( 2022,31,32,31,32,31,30,30,30,29,29,30,30),274 23 => array( 2023,31,32,31,32,31,30,30,30,29,30,29,31),275 24 => array( 2024,31,31,31,32,31,31,30,29,30,29,30,30),276 25 => array( 2025,31,31,32,31,31,31,30,29,30,29,30,30),277 26 => array( 2026,31,32,31,32,31,30,30,30,29,29,30,31),278 27 => array( 2027,30,32,31,32,31,30,30,30,29,30,29,31),279 28 => array( 2028,31,31,32,31,31,31,30,29,30,29,30,30),280 29 => array( 2029,31,31,32,31,32,30,30,29,30,29,30,30),281 30 => array( 2030,31,32,31,32,31,30,30,30,29,29,30,31),282 31 => array( 2031,30,32,31,32,31,30,30,30,29,30,29,31),283 32 => array( 2032,31,31,32,31,31,31,30,29,30,29,30,30),284 33 => array( 2033,31,31,32,32,31,30,30,29,30,29,30,30),285 34 => array( 2034,31,32,31,32,31,30,30,30,29,29,30,31),286 35 => array( 2035,30,32,31,32,31,31,29,30,30,29,29,31),287 36 => array( 2036,31,31,32,31,31,31,30,29,30,29,30,30),288 37 => array( 2037,31,31,32,32,31,30,30,29,30,29,30,30),289 38 => array( 2038,31,32,31,32,31,30,30,30,29,29,30,31),290 39 => array( 2039,31,31,31,32,31,31,29,30,30,29,30,30),291 40 => array( 2040,31,31,32,31,31,31,30,29,30,29,30,30),292 41 => array( 2041,31,31,32,32,31,30,30,29,30,29,30,30),293 42 => array( 2042,31,32,31,32,31,30,30,30,29,29,30,31),294 43 => array( 2043,31,31,31,32,31,31,29,30,30,29,30,30),295 44 => array( 2044,31,31,32,31,31,31,30,29,30,29,30,30),296 45 => array( 2045,31,32,31,32,31,30,30,29,30,29,30,30),297 46 => array( 2046,31,32,31,32,31,30,30,30,29,29,30,31),298 47 => array( 2047,31,31,31,32,31,31,30,29,30,29,30,30),299 48 => array( 2048,31,31,32,31,31,31,30,29,30,29,30,30),300 49 => array( 2049,31,32,31,32,31,30,30,30,29,29,30,30),301 50 => array( 2050,31,32,31,32,31,30,30,30,29,30,29,31),302 51 => array( 2051,31,31,31,32,31,31,30,29,30,29,30,30),303 52 => array( 2052,31,31,32,31,31,31,30,29,30,29,30,30),304 53 => array( 2053,31,32,31,32,31,30,30,30,29,29,30,30),305 54 => array( 2054,31,32,31,32,31,30,30,30,29,30,29,31),306 55 => array( 2055,31,31,32,31,31,31,30,29,30,29,30,30),307 56 => array( 2056,31,31,32,31,32,30,30,29,30,29,30,30),308 57 => array( 2057,31,32,31,32,31,30,30,30,29,29,30,31),309 58 => array( 2058,30,32,31,32,31,30,30,30,29,30,29,31),310 59 => array( 2059,31,31,32,31,31,31,30,29,30,29,30,30),311 60 => array( 2060,31,31,32,32,31,30,30,29,30,29,30,30),312 61 => array( 2061,31,32,31,32,31,30,30,30,29,29,30,31),313 62 => array( 2062,30,32,31,32,31,31,29,30,29,30,29,31),314 63 => array( 2063,31,31,32,31,31,31,30,29,30,29,30,30),315 64 => array( 2064,31,31,32,32,31,30,30,29,30,29,30,30),316 65 => array( 2065,31,32,31,32,31,30,30,30,29,29,30,31),317 66 => array( 2066,31,31,31,32,31,31,29,30,30,29,29,31),318 67 => array( 2067,31,31,32,31,31,31,30,29,30,29,30,30),319 68 => array( 2068,31,31,32,32,31,30,30,29,30,29,30,30),320 69 => array( 2069,31,32,31,32,31,30,30,30,29,29,30,31),321 70 => array( 2070,31,31,31,32,31,31,29,30,30,29,30,30),322 71 => array( 2071,31,31,32,31,31,31,30,29,30,29,30,30),323 72 => array( 2072,31,32,31,32,31,30,30,29,30,29,30,30),324 73 => array( 2073,31,32,31,32,31,30,30,30,29,29,30,31),325 74 => array( 2074,31,31,31,32,31,31,30,29,30,29,30,30),326 75 => array( 2075,31,31,32,31,31,31,30,29,30,29,30,30),327 76 => array( 2076,31,32,31,32,31,30,30,30,29,29,30,30),328 77 => array( 2077,31,32,31,32,31,30,30,30,29,30,29,31),329 78 => array( 2078,31,31,31,32,31,31,30,29,30,29,30,30),330 79 => array( 2079,31,31,32,31,31,31,30,29,30,29,30,30),331 80 => array( 2080,31,32,31,32,31,30,30,30,29,29,30,30),332 81 => array( 2081,31,31,32,32,31,30,30,30,29,30,30,30),333 82 => array( 2082,30,32,31,32,31,30,30,30,29,30,30,30),334 83 => array( 2083,31,31,32,31,31,30,30,30,29,30,30,30),335 84 => array( 2084,31,31,32,31,31,30,30,30,29,30,30,30),336 85 => array( 2085,31,32,31,32,30,31,30,30,29,30,30,30),337 86 => array( 2086,30,32,31,32,31,30,30,30,29,30,30,30),338 87 => array( 2087,31,31,32,31,31,31,30,30,29,30,30,30),339 88 => array( 2088,30,31,32,32,30,31,30,30,29,30,30,30),340 89 => array( 2089,30,32,31,32,31,30,30,30,29,30,30,30),341 90 => array( 2090,30,32,31,32,31,30,30,30,29,30,30,30)241 0 => array( 2000, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 242 1 => array( 2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 243 2 => array( 2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 244 3 => array( 2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 245 4 => array( 2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 246 5 => array( 2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 247 6 => array( 2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 248 7 => array( 2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 249 8 => array( 2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ), 250 9 => array( 2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 251 10 => array( 2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 252 11 => array( 2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 253 12 => array( 2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ), 254 13 => array( 2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 255 14 => array( 2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 256 15 => array( 2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 257 16 => array( 2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ), 258 17 => array( 2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 259 18 => array( 2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 260 19 => array( 2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 261 20 => array( 2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 262 21 => array( 2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 263 22 => array( 2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ), 264 23 => array( 2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 265 24 => array( 2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 266 25 => array( 2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 267 26 => array( 2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 268 27 => array( 2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 269 28 => array( 2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 270 29 => array( 2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ), 271 30 => array( 2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 272 31 => array( 2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 273 32 => array( 2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 274 33 => array( 2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 275 34 => array( 2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 276 35 => array( 2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ), 277 36 => array( 2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 278 37 => array( 2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 279 38 => array( 2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 280 39 => array( 2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ), 281 40 => array( 2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 282 41 => array( 2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 283 42 => array( 2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 284 43 => array( 2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ), 285 44 => array( 2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 286 45 => array( 2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 287 46 => array( 2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 288 47 => array( 2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 289 48 => array( 2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 290 49 => array( 2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ), 291 50 => array( 2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 292 51 => array( 2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 293 52 => array( 2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 294 53 => array( 2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ), 295 54 => array( 2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 296 55 => array( 2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 297 56 => array( 2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ), 298 57 => array( 2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 299 58 => array( 2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 300 59 => array( 2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 301 60 => array( 2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 302 61 => array( 2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 303 62 => array( 2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31 ), 304 63 => array( 2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 305 64 => array( 2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 306 65 => array( 2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 307 66 => array( 2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ), 308 67 => array( 2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 309 68 => array( 2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 310 69 => array( 2069, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 311 70 => array( 2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ), 312 71 => array( 2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 313 72 => array( 2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ), 314 73 => array( 2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ), 315 74 => array( 2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 316 75 => array( 2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 317 76 => array( 2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ), 318 77 => array( 2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ), 319 78 => array( 2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ), 320 79 => array( 2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ), 321 80 => array( 2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ), 322 81 => array( 2081, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ), 323 82 => array( 2082, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ), 324 83 => array( 2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ), 325 84 => array( 2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ), 326 85 => array( 2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30 ), 327 86 => array( 2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ), 328 87 => array( 2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30 ), 329 88 => array( 2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30 ), 330 89 => array( 2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ), 331 90 => array( 2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ), 342 332 ); 343 333 … … 348 338 * @access private 349 339 * @since 1.0 350 *351 340 */ 352 341 private $date_data = array( 353 'eng_date' =>array(354 'year' =>'',355 'month' =>'',356 'date' =>''342 'eng_date' => array( 343 'year' => '', 344 'month' => '', 345 'date' => '', 357 346 ), 358 'nep_date' =>array(359 'year' =>'',360 'month' =>'',361 'date' =>''347 'nep_date' => array( 348 'year' => '', 349 'month' => '', 350 'date' => '', 362 351 ), 363 'from' =>'',364 'result' =>'',352 'from' => '', 353 'result' => '', 365 354 366 355 ); … … 388 377 // Always return the instance 389 378 return $instance; 390 391 379 } 392 380 … … 399 387 * @return bool|string 400 388 */ 401 private function _is_in_range_eng( $yy, $mm, $dd) {402 if ( $yy < 1944 || $yy > 2033) {403 return __( "Supported only between 1944-2022",'nepali-date-converter');404 } 405 406 if ( $mm < 1 || $mm > 12) {407 return __( "Error! month value can be between 1-12 only",'nepali-date-converter');408 } 409 410 if ( $dd < 1 || $dd > 31) {411 return __( "Error! day value can be between 1-31 only",'nepali-date-converter');412 } 413 414 return TRUE;389 private function _is_in_range_eng( $yy, $mm, $dd ) { 390 if ( $yy < 1944 || $yy > 2033 ) { 391 return __( 'Supported only between 1944-2022', 'nepali-date-converter' ); 392 } 393 394 if ( $mm < 1 || $mm > 12 ) { 395 return __( 'Error! month value can be between 1-12 only', 'nepali-date-converter' ); 396 } 397 398 if ( $dd < 1 || $dd > 31 ) { 399 return __( 'Error! day value can be between 1-31 only', 'nepali-date-converter' ); 400 } 401 402 return true; 415 403 } 416 404 … … 423 411 * @return bool 424 412 */ 425 private function _is_in_range_nep( $yy, $mm, $dd) {426 if ( $yy < 2000 || $yy > 2089) {427 return __( "Supported only between 2000-2089",'nepali-date-converter');428 } 429 430 if ( $mm < 1 || $mm > 12) {431 return __( "Error! month value can be between 1-12 only",'nepali-date-converter');432 } 433 434 if ( $dd < 1 || $dd > 32) {435 return __( "Error! day value can be between 1-31 only",'nepali-date-converter');436 } 437 438 return TRUE;413 private function _is_in_range_nep( $yy, $mm, $dd ) { 414 if ( $yy < 2000 || $yy > 2089 ) { 415 return __( 'Supported only between 2000-2089', 'nepali-date-converter' ); 416 } 417 418 if ( $mm < 1 || $mm > 12 ) { 419 return __( 'Error! month value can be between 1-12 only', 'nepali-date-converter' ); 420 } 421 422 if ( $dd < 1 || $dd > 32 ) { 423 return __( 'Error! day value can be between 1-31 only', 'nepali-date-converter' ); 424 } 425 426 return true; 439 427 } 440 428 … … 445 433 * @return bool 446 434 */ 447 public function is_leap_year( $year) {435 public function is_leap_year( $year ) { 448 436 $a = $year; 449 if ($a % 100 == 0) { 450 if ($a % 400 == 0) 451 { 452 return TRUE; 453 } 454 else 455 { 456 return FALSE; 457 } 458 } 459 else { 460 if ($a % 4 == 0) 461 { 462 return TRUE; 463 } 464 else 465 { 466 return FALSE; 467 } 437 if ( $a % 100 == 0 ) { 438 if ( $a % 400 == 0 ) { 439 return true; 440 } else { 441 return false; 442 } 443 } elseif ( $a % 4 == 0 ) { 444 445 return true; 446 } else { 447 return false; 468 448 } 469 449 } … … 477 457 * @return array 478 458 */ 479 public function eng_to_nep( $input_date = array(), $date_format = 'nep_char', $format = 'D, F j, Y' ) {459 public function eng_to_nep( $input_date = array(), $date_format = 'nep_char', $format = 'D, F j, Y' ) { 480 460 481 461 // Check for date range … … 484 464 $dd = $input_date['day']; 485 465 486 $chk = $this->_is_in_range_eng($yy, $mm, $dd); 487 488 if($chk !== TRUE) { 489 die($chk); 490 } 491 else { 492 493 $this->date_data['from'] = 'eng'; 494 $this->date_data['eng_date']['year']= $yy; 495 $this->date_data['eng_date']['month']= $mm; 496 $this->date_data['eng_date']['date']= $dd; 466 $chk = $this->_is_in_range_eng( $yy, $mm, $dd ); 467 468 if ( $chk !== true ) { 469 die( $chk ); 470 } else { 471 472 $this->date_data['from'] = 'eng'; 473 $this->date_data['eng_date']['year'] = $yy; 474 $this->date_data['eng_date']['month'] = $mm; 475 $this->date_data['eng_date']['date'] = $dd; 497 476 // Month data. 498 $month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);477 $month = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); 499 478 500 479 // Month for leap year 501 $lmonth = array( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);502 503 $def_eyy = 1944; // initial english date.480 $lmonth = array( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); 481 482 $def_eyy = 1944; // initial english date. 504 483 $def_nyy = 2000; 505 484 $def_nmm = 9; 506 $def_ndd = 17 - 1; // inital nepali date.485 $def_ndd = 17 - 1; // inital nepali date. 507 486 $total_eDays = 0; 508 $np_date = 0;487 $np_date = 0; 509 488 $a = 0; 510 489 $day = 7 - 1; … … 516 495 517 496 // Count total no. of days in-terms year 518 for ($i = 0; $i < ($yy - $def_eyy); $i++) //total days for month calculation...(english) 519 { 520 if ($this->is_leap_year($def_eyy + $i) === TRUE) 521 { 522 for ($j = 0; $j < 12; $j++) 523 { 524 $total_eDays += $lmonth[$j]; 497 for ( $i = 0; $i < ( $yy - $def_eyy ); $i++ ) { 498 if ( $this->is_leap_year( $def_eyy + $i ) === true ) { 499 for ( $j = 0; $j < 12; $j++ ) { 500 $total_eDays += $lmonth[ $j ]; 525 501 } 526 } 527 else 528 { 529 for ($j = 0; $j < 12; $j++) 530 { 531 $total_eDays += $month[$j]; 502 } else { 503 for ( $j = 0; $j < 12; $j++ ) { 504 $total_eDays += $month[ $j ]; 532 505 } 533 506 } … … 535 508 536 509 // Count total no. of days in-terms of month 537 for ($i = 0; $i < ($mm - 1); $i++) 538 { 539 if ($this->is_leap_year($yy) === TRUE) 540 { 541 $total_eDays += $lmonth[$i]; 542 } 543 else 544 { 545 $total_eDays += $month[$i]; 510 for ( $i = 0; $i < ( $mm - 1 ); $i++ ) { 511 if ( $this->is_leap_year( $yy ) === true ) { 512 $total_eDays += $lmonth[ $i ]; 513 } else { 514 $total_eDays += $month[ $i ]; 546 515 } 547 516 } … … 550 519 $total_eDays += $dd; 551 520 552 553 $i = 0; 554 $j = $def_nmm; 521 $i = 0; 522 $j = $def_nmm; 555 523 $np_date = $def_ndd; 556 $m = $def_nmm;557 $y = $def_nyy;524 $m = $def_nmm; 525 $y = $def_nyy; 558 526 559 527 // Count nepali date from array 560 while ($total_eDays != 0) 561 { 562 $a = $this->_c_bs[$i][$j]; 563 564 $np_date++; //count the days 565 $day++; //count the days interms of 7 days 566 567 if ($np_date > $a) 568 { 569 $m++; 528 while ( $total_eDays != 0 ) { 529 $a = $this->_c_bs[ $i ][ $j ]; 530 531 ++$np_date; // count the days 532 ++$day; // count the days interms of 7 days 533 534 if ( $np_date > $a ) { 535 ++$m; 570 536 $np_date = 1; 571 $j++; 572 } 573 574 if ($day > 7) 575 { 537 ++$j; 538 } 539 540 if ( $day > 7 ) { 576 541 $day = 1; 577 542 } 578 543 579 if ($m > 12) 580 { 581 $y++; 544 if ( $m > 12 ) { 545 ++$y; 582 546 $m = 1; 583 547 } 584 548 585 if ($j > 12) 586 { 549 if ( $j > 12 ) { 587 550 $j = 1; 588 $i++; 589 } 590 591 $total_eDays--; 592 } 593 594 /*Date Formatting 551 ++$i; 552 } 553 554 --$total_eDays; 555 } 556 557 /* 558 Date Formatting 595 559 * no supported 596 560 S, c, r, U 597 may be c= $y.'-'.$m.'-'.$np_date.'स'.date('H',$create_date).':'.date('i',$create_date).':'.date('s',$create_date).'+00:00',561 may be c= $y.'-'.$m.'-'.$np_date.'स'.date('H',$create_date).':'.date('i',$create_date).':'.date('s',$create_date).'+00:00', 598 562 */ 599 563 /*Optional*/ 600 $hour = isset( $input_date['hour'])?$input_date['hour']:'';601 $min = isset($input_date['min'])?$input_date['min']:'';602 $sec = isset($input_date['sec'])?$input_date['sec']:'';603 604 $ndcDateStr = $yy .'-'.$mm.'-'.$dd;605 if ( $hour){606 $ndcDateStr .= ' ' .$hour;607 } 608 if ( $min){609 $ndcDateStr .= ':' .$min;610 } 611 if ( $sec){612 $ndcDateStr .= ':' .$sec;564 $hour = isset( $input_date['hour'] ) ? $input_date['hour'] : ''; 565 $min = isset( $input_date['min'] ) ? $input_date['min'] : ''; 566 $sec = isset( $input_date['sec'] ) ? $input_date['sec'] : ''; 567 568 $ndcDateStr = $yy . '-' . $mm . '-' . $dd; 569 if ( $hour ) { 570 $ndcDateStr .= ' ' . $hour; 571 } 572 if ( $min ) { 573 $ndcDateStr .= ':' . $min; 574 } 575 if ( $sec ) { 576 $ndcDateStr .= ':' . $sec; 613 577 } 614 578 … … 616 580 617 581 $ndp_format = array( 618 'd' => $this->getTwoCharStr($np_date),/*add 0 to front if one character*/619 'j' => $np_date,/*always j */620 'l' => date('l',$create_date),621 'D' => date('D',$create_date),622 'm' => $this->getTwoCharStr($m),623 'n' => $m,624 'F' => array_keys($this->long_eng_nep_mth)[(int)$m-1],625 'M' => array_keys($this->short_eng_nep_mth)[(int)$m-1],626 'Y' => $y,627 'y' => substr($y, 2),628 'a' => date('a',$create_date),629 'A' => date('A',$create_date),630 'g' => date('g',$create_date),631 'h' => date('h',$create_date),632 'G' => date('G',$create_date),633 'H' => date('H',$create_date),634 'i' => date('i',$create_date),635 's' => date('s',$create_date),636 'T' => date('T',$create_date),637 'c' => $y.'-'.$m.'-'.$np_date.'स'.date('H',$create_date).':'.date('i',$create_date).':'.date('s',$create_date).'+00:00',638 'r' => date('D',$create_date).', '.$np_date.' '.array_keys($this->short_eng_nep_mth)[(int)$m-1].' '.$y.' '.date('H',$create_date).':'.date('i',$create_date).':'.date('s',$create_date).'+0200'582 'd' => $this->getTwoCharStr( $np_date ), /*add 0 to front if one character*/ 583 'j' => $np_date, /*always j */ 584 'l' => date( 'l', $create_date ), 585 'D' => date( 'D', $create_date ), 586 'm' => $this->getTwoCharStr( $m ), 587 'n' => $m, 588 'F' => array_keys( $this->long_eng_nep_mth )[ (int) $m - 1 ], 589 'M' => array_keys( $this->short_eng_nep_mth )[ (int) $m - 1 ], 590 'Y' => $y, 591 'y' => substr( $y, 2 ), 592 'a' => date( 'a', $create_date ), 593 'A' => date( 'A', $create_date ), 594 'g' => date( 'g', $create_date ), 595 'h' => date( 'h', $create_date ), 596 'G' => date( 'G', $create_date ), 597 'H' => date( 'H', $create_date ), 598 'i' => date( 'i', $create_date ), 599 's' => date( 's', $create_date ), 600 'T' => date( 'T', $create_date ), 601 'c' => $y . '-' . $m . '-' . $np_date . 'स' . date( 'H', $create_date ) . ':' . date( 'i', $create_date ) . ':' . date( 's', $create_date ) . '+00:00', 602 'r' => date( 'D', $create_date ) . ', ' . $np_date . ' ' . array_keys( $this->short_eng_nep_mth )[ (int) $m - 1 ] . ' ' . $y . ' ' . date( 'H', $create_date ) . ':' . date( 'i', $create_date ) . ':' . date( 's', $create_date ) . '+0200', 639 603 ); 640 604 … … 642 606 643 607 /*current actual date stored as temp*/ 644 $temp_long_actual_nepali_day = 'coder'.$day.'nepal';645 $temp_short_actual_nepali_day = 'coder' .$day.'nep';646 $temp_long_eng_nep_day = array(647 "Sunday"=> $temp_long_actual_nepali_day,648 "Monday"=> $temp_long_actual_nepali_day,649 "Tuesday"=> $temp_long_actual_nepali_day,650 "Wednesday"=> $temp_long_actual_nepali_day,651 "Thursday"=> $temp_long_actual_nepali_day,652 "Friday"=> $temp_long_actual_nepali_day,653 "Saturday"=> $temp_long_actual_nepali_day608 $temp_long_actual_nepali_day = 'coder' . $day . 'nepal'; 609 $temp_short_actual_nepali_day = 'coder' . $day . 'nep'; 610 $temp_long_eng_nep_day = array( 611 'Sunday' => $temp_long_actual_nepali_day, 612 'Monday' => $temp_long_actual_nepali_day, 613 'Tuesday' => $temp_long_actual_nepali_day, 614 'Wednesday' => $temp_long_actual_nepali_day, 615 'Thursday' => $temp_long_actual_nepali_day, 616 'Friday' => $temp_long_actual_nepali_day, 617 'Saturday' => $temp_long_actual_nepali_day, 654 618 ); 655 $temp_short_eng_nep_day = array(656 "Sun"=> $temp_short_actual_nepali_day,657 "Mon"=> $temp_short_actual_nepali_day,658 "Tue"=> $temp_short_actual_nepali_day,659 "Wed"=> $temp_short_actual_nepali_day,660 "Thu"=> $temp_short_actual_nepali_day,661 "Fri"=> $temp_short_actual_nepali_day,662 "Sat"=> $temp_short_actual_nepali_day619 $temp_short_eng_nep_day = array( 620 'Sun' => $temp_short_actual_nepali_day, 621 'Mon' => $temp_short_actual_nepali_day, 622 'Tue' => $temp_short_actual_nepali_day, 623 'Wed' => $temp_short_actual_nepali_day, 624 'Thu' => $temp_short_actual_nepali_day, 625 'Fri' => $temp_short_actual_nepali_day, 626 'Sat' => $temp_short_actual_nepali_day, 663 627 ); 664 628 665 if ( 'eng_char' == $date_format ){629 if ( 'eng_char' == $date_format ) { 666 630 $nepali_date = strtr( $nepali_date, $this->long_eng_nep_mth_in_eng ); 667 631 $nepali_date = strtr( $nepali_date, $this->short_eng_nep_mth_in_eng ); 668 632 669 $actual_long_nepali_day = array(670 "coder1nepal"=> 'Aaitabar',671 "coder2nepal"=> 'Sombar',672 "coder3nepal"=> 'Mangalbar',673 "coder4nepal"=> 'Budhabar',674 "coder5nepal"=> 'Bihibar',675 "coder6nepal"=> 'Sukrabar',676 "coder7nepal"=> 'Sanibar'633 $actual_long_nepali_day = array( 634 'coder1nepal' => 'Aaitabar', 635 'coder2nepal' => 'Sombar', 636 'coder3nepal' => 'Mangalbar', 637 'coder4nepal' => 'Budhabar', 638 'coder5nepal' => 'Bihibar', 639 'coder6nepal' => 'Sukrabar', 640 'coder7nepal' => 'Sanibar', 677 641 ); 678 642 $actual_short_nepali_day = array( 679 "coder1nep"=> 'Aaita',680 "coder2nep"=> 'Som',681 "coder3nep"=> 'Mangal',682 "coder4nep"=> 'Budha',683 "coder5nep"=> 'Bihi',684 "coder6nep"=> 'Sukra',685 "coder7nep"=> 'Sani'643 'coder1nep' => 'Aaita', 644 'coder2nep' => 'Som', 645 'coder3nep' => 'Mangal', 646 'coder4nep' => 'Budha', 647 'coder5nep' => 'Bihi', 648 'coder6nep' => 'Sukra', 649 'coder7nep' => 'Sani', 686 650 ); 687 651 /*changing the day*/ … … 693 657 /*AM/PM*/ 694 658 $amPmTranslate = array( 695 "am"=> 'Bihana',696 "pm"=> 'Madyana',659 'am' => 'Bihana', 660 'pm' => 'Madyana', 697 661 ); 698 $nepali_date = strtr( $nepali_date, $amPmTranslate ); 699 } 700 else{ 662 $nepali_date = strtr( $nepali_date, $amPmTranslate ); 663 } else { 701 664 $nepali_date = strtr( $nepali_date, $this->eng_nep_num ); 702 665 $nepali_date = strtr( $nepali_date, $this->long_eng_nep_mth ); 703 666 $nepali_date = strtr( $nepali_date, $this->short_eng_nep_mth ); 704 667 705 $actual_long_nepali_day = array(706 "coder1nepal"=> 'आइतवार',707 "coder2nepal"=> 'सोमवार',708 "coder3nepal"=> 'मङ्लबार',709 "coder4nepal"=> 'बुधबार',710 "coder5nepal"=> 'बिहिबार',711 "coder6nepal"=> 'शुक्रबार',712 "coder7nepal"=> 'शनिबार'668 $actual_long_nepali_day = array( 669 'coder1nepal' => 'आइतवार', 670 'coder2nepal' => 'सोमवार', 671 'coder3nepal' => 'मङ्लबार', 672 'coder4nepal' => 'बुधबार', 673 'coder5nepal' => 'बिहिबार', 674 'coder6nepal' => 'शुक्रबार', 675 'coder7nepal' => 'शनिबार', 713 676 ); 714 677 $actual_short_nepali_day = array( 715 "coder1nep"=> 'आइत',716 "coder2nep"=> 'सोम',717 "coder3nep"=> 'मङ्ल',718 "coder4nep"=> 'बुध',719 "coder5nep"=> 'बिहि',720 "coder6nep"=> 'शुक्र',721 "coder7nep"=> 'शनि'678 'coder1nep' => 'आइत', 679 'coder2nep' => 'सोम', 680 'coder3nep' => 'मङ्ल', 681 'coder4nep' => 'बुध', 682 'coder5nep' => 'बिहि', 683 'coder6nep' => 'शुक्र', 684 'coder7nep' => 'शनि', 722 685 ); 723 686 … … 730 693 /*AM/PM*/ 731 694 $amPmTranslate = array( 732 "am"=> 'बिहान',733 "pm"=> 'मध्यान्ह',695 'am' => 'बिहान', 696 'pm' => 'मध्यान्ह', 734 697 ); 735 $nepali_date = strtr( $nepali_date, $amPmTranslate );736 } 737 738 $this->date_data['nep_date']['year'] = $y;739 $this->date_data['nep_date']['month'] = $m;740 $this->date_data['nep_date']['date'] = $np_date;741 $this->date_data['result'] = $nepali_date;698 $nepali_date = strtr( $nepali_date, $amPmTranslate ); 699 } 700 701 $this->date_data['nep_date']['year'] = $y; 702 $this->date_data['nep_date']['month'] = $m; 703 $this->date_data['nep_date']['date'] = $np_date; 704 $this->date_data['result'] = $nepali_date; 742 705 return $this->date_data; 743 706 } … … 753 716 * @return array 754 717 */ 755 public function nep_to_eng( $input_date = array() ,$format = 'D, F j, Y' ) {718 public function nep_to_eng( $input_date = array(), $format = 'D, F j, Y' ) { 756 719 // Check for date range 757 $yy = $input_date['year'];758 $mm = $input_date['month'];759 $dd = $input_date['day'];720 $yy = $input_date['year']; 721 $mm = $input_date['month']; 722 $dd = $input_date['day']; 760 723 $def_eyy = 1943; 761 724 $def_emm = 4; 762 $def_edd = 14 - 1; // initial english date.725 $def_edd = 14 - 1; // initial english date. 763 726 $def_nyy = 2000; 764 727 $def_nmm = 1; 765 $def_ndd = 1; // iniital equivalent nepali date.728 $def_ndd = 1; // iniital equivalent nepali date. 766 729 $total_eDays = 0; 767 $np_date = 0;730 $np_date = 0; 768 731 $a = 0; 769 732 $day = 4 - 1; … … 787 750 31, 788 751 30, 789 31 752 31, 790 753 ); 791 754 $lmonth = array( … … 802 765 31, 803 766 30, 804 31 767 31, 805 768 ); 806 769 807 770 // Check for date range 808 $chk = $this->_is_in_range_nep($yy, $mm, $dd); 809 810 if ( $chk !== TRUE) 811 { 812 die($chk); 813 } 814 else 815 { 816 $this->date_data['from'] = 'nep'; 817 $this->date_data['nep_date']['year']= $yy; 818 $this->date_data['nep_date']['month']= $mm; 819 $this->date_data['nep_date']['date']= $dd; 771 $chk = $this->_is_in_range_nep( $yy, $mm, $dd ); 772 773 if ( $chk !== true ) { 774 die( $chk ); 775 } else { 776 $this->date_data['from'] = 'nep'; 777 $this->date_data['nep_date']['year'] = $yy; 778 $this->date_data['nep_date']['month'] = $mm; 779 $this->date_data['nep_date']['date'] = $dd; 820 780 821 781 // Count total days in-terms of year 822 for ($i = 0; $i < ($yy - $def_nyy); $i++) 823 { 824 for ($j = 1; $j <= 12; $j++) 825 { 826 $np_date += $this->_c_bs[$k][$j]; 827 } 828 $k++; 782 for ( $i = 0; $i < ( $yy - $def_nyy ); $i++ ) { 783 for ( $j = 1; $j <= 12; $j++ ) { 784 $np_date += $this->_c_bs[ $k ][ $j ]; 785 } 786 ++$k; 829 787 } 830 788 831 789 // Count total days in-terms of month 832 for ($j = 1; $j < $mm; $j++) 833 { 834 $np_date += $this->_c_bs[$k][$j]; 790 for ( $j = 1; $j < $mm; $j++ ) { 791 $np_date += $this->_c_bs[ $k ][ $j ]; 835 792 } 836 793 … … 842 799 $m = $def_emm; 843 800 $y = $def_eyy; 844 while ($np_date != 0) 845 { 846 if ($this->is_leap_year($y)) 847 { 848 $a = $lmonth[$m]; 849 } 850 else 851 { 852 $a = $month[$m]; 853 } 854 855 $total_eDays++; 856 $day++; 857 858 if ($total_eDays > $a) 859 { 860 $m++; 801 while ( $np_date != 0 ) { 802 if ( $this->is_leap_year( $y ) ) { 803 $a = $lmonth[ $m ]; 804 } else { 805 $a = $month[ $m ]; 806 } 807 808 ++$total_eDays; 809 ++$day; 810 811 if ( $total_eDays > $a ) { 812 ++$m; 861 813 $total_eDays = 1; 862 if ($m > 12) 863 { 864 $y++; 814 if ( $m > 12 ) { 815 ++$y; 865 816 $m = 1; 866 817 } 867 818 } 868 819 869 if ($day > 7) 870 { 820 if ( $day > 7 ) { 871 821 $day = 1; 872 822 } 873 823 874 $np_date--;875 } 876 877 $date_formatting_string = $y .'-'.$m.'-'.$total_eDays;878 $create_date = date_create( $date_formatting_string );879 $formatted_date = date_format( $create_date, $format );880 881 $this->date_data['eng_date']['year'] = $y;882 $this->date_data['eng_date']['month'] = $m;883 $this->date_data['eng_date']['date'] = $total_eDays;884 $this->date_data['result'] = $formatted_date;824 --$np_date; 825 } 826 827 $date_formatting_string = $y . '-' . $m . '-' . $total_eDays; 828 $create_date = date_create( $date_formatting_string ); 829 $formatted_date = date_format( $create_date, $format ); 830 831 $this->date_data['eng_date']['year'] = $y; 832 $this->date_data['eng_date']['month'] = $m; 833 $this->date_data['eng_date']['date'] = $total_eDays; 834 $this->date_data['result'] = $formatted_date; 885 835 886 836 return $this->date_data; … … 896 846 * @since 2.0.0 897 847 */ 898 if ( !function_exists( 'ndc_nepali_calendar')){848 if ( ! function_exists( 'ndc_nepali_calendar' ) ) { 899 849 900 850 function ndc_nepali_calendar() { -
nepali-date-converter/trunk/nepali-date-converter.php
r3066175 r3103095 4 4 Plugin URI: https://www.addonspress.com/wordpress-plugins/nepali-date-converter/ 5 5 Description: Convert English to Nepali Date and Vice Versa and Post Date to Nepali Date. 6 Version: 2.0. 66 Version: 2.0.7 7 7 Author: addonspress 8 8 Author URI: https://www.addonspress.com/ … … 17 17 } 18 18 /*Define Constants for this plugin*/ 19 define( 'NEPALI_DATE_CONVERTER_VERSION', '2.0. 6' );19 define( 'NEPALI_DATE_CONVERTER_VERSION', '2.0.7' ); 20 20 define( 'NEPALI_DATE_CONVERTER_PATH', plugin_dir_path( __FILE__ ) ); 21 21 define( 'NEPALI_DATE_CONVERTER_URL', plugin_dir_url( __FILE__ ) ); -
nepali-date-converter/trunk/readme.txt
r3066175 r3103095 5 5 Requires at least: 4.9 6 6 Tested up to: 6.5 7 Stable tag: 2.0. 67 Stable tag: 2.0.7 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 12 12 13 13 == Description == 14 15 If you're looking for a sleek and functional WordPress theme that integrates seamlessly with a Nepali date converter plugin, 16 check out this [free WordPress theme: CosmosWP](https://wordpress.org/themes/cosmoswp/). It comes with a [demo showcasing the Nepali date converter](https://demo.cosmoswp.com/demo-99/) plugin in action. 14 17 15 18 Newly Added Feature: Convert Post Dates to Nepali Dates. Access the setting under Admin => Setting => General. … … 137 140 == Changelog == 138 141 139 = 2.0.6 - 2023-04-07 = 142 = 2.0.7 - 2024-06-15 = 143 * Fixed : [Date issue](https://wordpress.org/support/topic/jestha-32-is-not-showing/) 144 145 = 2.0.6 - 2024-04-07 = 140 146 * Updated : Tested up WordPress 6.5 141 147
Note: See TracChangeset
for help on using the changeset viewer.