|  | 
| 4 | 4 |     <meta charset="UTF-8"> | 
| 5 | 5 |     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 
| 6 | 6 |     <title>Bikram Calendar</title> | 
| 7 |  | -    <link href="https://fonts.googleapis.com/css2?family=laila:wght@400;500&display=swap" rel="stylesheet"> | 
|  | 7 | +    <link href="https://fonts.googleapis.com/css2?family=Laila:wght@400;500&display=swap" rel="stylesheet"> | 
| 8 | 8 |     <script type="text/javascript" src="bikram.js"></script> | 
| 9 | 9 |     <script type="text/javascript" src="tithi.js"></script> | 
| 10 | 10 |     <style> | 
|  | 
| 46 | 46 |             border: 1px solid #ddd; | 
| 47 | 47 |             border-radius: 4px; | 
| 48 | 48 |             background-color: #f1f1f1; | 
| 49 |  | -            font-size: 16px; | 
| 50 | 49 |             flex: 1 1 auto; | 
| 51 | 50 |         } | 
| 52 | 51 | 
 | 
|  | 
| 69 | 68 | 
 | 
| 70 | 69 |         table { | 
| 71 | 70 |             width: 100%; | 
| 72 |  | -            | 
| 73 | 71 |             margin-top: 20px; | 
| 74 | 72 |             table-layout: fixed; | 
| 75 | 73 |         } | 
|  | 
| 79 | 77 |             padding: 10px; | 
| 80 | 78 |             text-align: center; | 
| 81 | 79 |             font-weight: bold; | 
|  | 80 | +            position: relative;  | 
|  | 81 | +            cursor: pointer; | 
| 82 | 82 |         } | 
| 83 | 83 | 
 | 
| 84 | 84 |         th { | 
|  | 
| 89 | 89 |         td { | 
| 90 | 90 |             height: 60px; | 
| 91 | 91 |             vertical-align: top; | 
|  | 92 | +            position: relative;  | 
| 92 | 93 |         } | 
| 93 | 94 | 
 | 
| 94 | 95 |         tr:first-child td:first-child { | 
|  | 
| 196 | 197 |             } | 
| 197 | 198 |         } | 
| 198 | 199 |         .modal { | 
| 199 |  | -        display: none; | 
| 200 |  | -        position: fixed; | 
| 201 |  | -        z-index: 1; | 
| 202 |  | -        left: 0; | 
| 203 |  | -        top: 0; | 
| 204 |  | -        width: 100%; | 
| 205 |  | -        height: 100%; | 
| 206 |  | -        overflow: auto; | 
| 207 |  | -        background-color: rgb(0,0,0); | 
| 208 |  | -        background-color: rgba(0,0,0,0.4); | 
| 209 |  | -        padding-top: 60px; | 
| 210 |  | -    } | 
|  | 200 | +            display: none; | 
|  | 201 | +            position: fixed; | 
|  | 202 | +            z-index: 1; | 
|  | 203 | +            left: 0; | 
|  | 204 | +            top: 0; | 
|  | 205 | +            width: 100%; | 
|  | 206 | +            height: 100%; | 
|  | 207 | +            overflow: auto; | 
|  | 208 | +            background-color: rgb(0,0,0); | 
|  | 209 | +            background-color: rgba(0,0,0,0.4); | 
|  | 210 | +            padding-top: 60px; | 
|  | 211 | +        } | 
| 211 | 212 | 
 | 
| 212 |  | -    .modal-content { | 
| 213 |  | -        background-color: #fefefe; | 
| 214 |  | -        margin: 5% auto; | 
| 215 |  | -        padding: 20px; | 
| 216 |  | -        border: 1px solid #888; | 
| 217 |  | -        width: 80%; | 
| 218 |  | -        max-width: 500px; | 
| 219 |  | -        border-radius: 8px; | 
| 220 |  | -        text-align: center; | 
| 221 |  | -    } | 
|  | 213 | +        .modal-content { | 
|  | 214 | +            background-color: #fefefe; | 
|  | 215 | +            margin: 5% auto; | 
|  | 216 | +            padding: 20px; | 
|  | 217 | +            border: 1px solid #888; | 
|  | 218 | +            width: 80%; | 
|  | 219 | +            max-width: 500px; | 
|  | 220 | +            border-radius: 8px; | 
|  | 221 | +            text-align: center; | 
|  | 222 | +        } | 
| 222 | 223 | 
 | 
| 223 |  | -    .close { | 
| 224 |  | -        color: #aaa; | 
| 225 |  | -        float: right; | 
| 226 |  | -        font-size: 28px; | 
| 227 |  | -        font-weight: bold; | 
| 228 |  | -    } | 
|  | 224 | +        .close { | 
|  | 225 | +            color: #aaa; | 
|  | 226 | +            float: right; | 
|  | 227 | +            font-size: 28px; | 
|  | 228 | +            font-weight: bold; | 
|  | 229 | +        } | 
| 229 | 230 | 
 | 
| 230 |  | -    .close:hover, | 
| 231 |  | -    .close:focus { | 
| 232 |  | -        color: black; | 
| 233 |  | -        text-decoration: none; | 
| 234 |  | -        cursor: pointer; | 
| 235 |  | -    } | 
| 236 |  | -    .tithi { | 
| 237 |  | -    color: #106bdb;  | 
| 238 |  | -    font-size: 10px;  | 
| 239 |  | -} | 
| 240 |  | -.gregorian { | 
| 241 |  | -    color: rgb(152, 191, 25); | 
|  | 231 | +        .close:hover, | 
|  | 232 | +        .close:focus { | 
|  | 233 | +            color: black; | 
|  | 234 | +            text-decoration: none; | 
|  | 235 | +            cursor: pointer; | 
|  | 236 | +        } | 
|  | 237 | + | 
|  | 238 | +        .tithi { | 
|  | 239 | +            color: #106bdb;  | 
|  | 240 | +            font-size: xx-small;  | 
|  | 241 | +        } | 
|  | 242 | + | 
|  | 243 | +        .gregorian { | 
|  | 244 | +            color: rgb(231 175 68); | 
|  | 245 | +            font-size: 65%; | 
|  | 246 | +            position: absolute;  | 
|  | 247 | +            bottom: 2px;  | 
|  | 248 | +            left: 2px;  | 
|  | 249 | +            margin: 2px; | 
|  | 250 | +        } | 
|  | 251 | + | 
|  | 252 | +        .gregorian-month-display { | 
|  | 253 | +    /* margin-right: 38px; */ | 
| 242 | 254 |     font-size: x-small; | 
| 243 |  | -    position: relative; | 
| 244 |  | -    bottom: -10px; | 
| 245 |  | -    left: -32px; | 
| 246 |  | -    margin: 2px; | 
|  | 255 | +    color: #827a7a; | 
|  | 256 | +    display: flex; | 
|  | 257 | +    flex-direction: column; | 
|  | 258 | +    flex-wrap: wrap; | 
|  | 259 | +    justify-content: flex-end; | 
| 247 | 260 | } | 
| 248 | 261 | 
 | 
|  | 262 | + | 
| 249 | 263 |     </style> | 
| 250 | 264 | </head> | 
| 251 | 265 | <body> | 
| @@ -332,8 +346,13 @@ <h1>विक्रम सम्बत क्यालेण्डर</h1> | 
| 332 | 346 | 
 | 
| 333 | 347 |     const defaultLanguage = "nepali"; | 
| 334 | 348 |     const monthName = getMonthNameWithDefaultLanguage(month, defaultLanguage); | 
|  | 349 | +    const gregorianStart = getGregorianDate(year, month, 1); | 
|  | 350 | +    const gregorianEnd = getLastDayOfGregorian(year, month); | 
|  | 351 | + | 
|  | 352 | +    const gregorianMonthDisplay = formatGregorianMonthDisplay(gregorianStart, gregorianEnd); | 
|  | 353 | + | 
| 335 | 354 | 
 | 
| 336 |  | -    let calendarHTML = `<h2>${monthName} ${convertToDevanagari(year)}</h2><table><tr>`; | 
|  | 355 | +    let calendarHTML = `<h2>${monthName} ${convertToDevanagari(year)} <span class="gregorian-month-display">${gregorianMonthDisplay}</span></h2><table><tr>`; | 
| 337 | 356 | 
 | 
| 338 | 357 |     const weekdays = ['आइतवार', 'सोमवार', 'मङ्गलवार', 'बुधवार', 'बिहीवार', 'शुक्रवार', 'शनिवार'];  // Nepali weekdays | 
| 339 | 358 | 
 | 
| @@ -529,6 +548,40 @@ <h1>विक्रम सम्बत क्यालेण्डर</h1> | 
| 529 | 548 |             generateCalendar(currentYear, currentMonth); | 
| 530 | 549 |         } | 
| 531 | 550 | 
 | 
|  | 551 | +        function getGregorianDate(year, month, day) { | 
|  | 552 | +    const bikram = new Bikram(); | 
|  | 553 | +    return bikram.toGregorian(year, month, day); | 
|  | 554 | +} | 
|  | 555 | + | 
|  | 556 | +function getLastDayOfGregorian(year, month) { | 
|  | 557 | +    const bikram = new Bikram(); | 
|  | 558 | +    const nextMonthFirstDay = bikram.toGregorian(year, month + 1, 1); | 
|  | 559 | +    const lastDayOfMonth = new Date(nextMonthFirstDay.year, nextMonthFirstDay.month - 1, nextMonthFirstDay.day - 1); | 
|  | 560 | +    return { | 
|  | 561 | +        day: lastDayOfMonth.getDate(), | 
|  | 562 | +        month: lastDayOfMonth.getMonth() + 1, // months are 0-indexed in JavaScript Date | 
|  | 563 | +        year: lastDayOfMonth.getFullYear() | 
|  | 564 | +    }; | 
|  | 565 | +} | 
|  | 566 | + | 
|  | 567 | +function getGregorianMonthName(month) { | 
|  | 568 | +    const gregorianMonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | 
|  | 569 | +    return gregorianMonths[month - 1]; | 
|  | 570 | +} | 
|  | 571 | + | 
|  | 572 | +function formatGregorianMonthDisplay(gregorianStart, gregorianEnd) { | 
|  | 573 | +    if (gregorianStart.year === gregorianEnd.year) { | 
|  | 574 | +        if (gregorianStart.month === gregorianEnd.month) { | 
|  | 575 | +            return `${gregorianStart.year} ${getGregorianMonthName(gregorianStart.month)}`; | 
|  | 576 | +        } else { | 
|  | 577 | +            return `${gregorianStart.year} ${getGregorianMonthName(gregorianStart.month)}/${getGregorianMonthName(gregorianEnd.month)}`; | 
|  | 578 | +        } | 
|  | 579 | +    } else { | 
|  | 580 | +        return `${gregorianStart.year}/${gregorianEnd.year} ${getGregorianMonthName(gregorianStart.month)}/${getGregorianMonthName(gregorianEnd.month)}`; | 
|  | 581 | +    } | 
|  | 582 | +} | 
|  | 583 | + | 
|  | 584 | + | 
| 532 | 585 |         window.onload = showCurrentMonth; | 
| 533 | 586 |     </script> | 
| 534 | 587 | </body> | 
|  | 
0 commit comments