Skip to content

Instantly share code, notes, and snippets.

@xardit
Last active June 19, 2024 16:03
Show Gist options
  • Save xardit/2eb9f5584fc7d8045982d6ded68407f0 to your computer and use it in GitHub Desktop.
Save xardit/2eb9f5584fc7d8045982d6ded68407f0 to your computer and use it in GitHub Desktop.

Revisions

  1. xardit revised this gist Jun 19, 2024. 1 changed file with 20 additions and 16 deletions.
    36 changes: 20 additions & 16 deletions month2sq.js
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,22 @@
    const month2sq = {
    January: 'Janar',
    February: 'Shkurt',
    March: 'Mars',
    April: 'Prill',
    May: 'Maj',
    June: 'Qershor',
    July: 'Korrik',
    August: 'Gusht',
    September: 'Shtator',
    October: 'Tetor',
    November: 'Nëntor',
    December: 'Dhjetor',
    January: 'Janar',
    February: 'Shkurt',
    March: 'Mars',
    April: 'Prill',
    May: 'Maj',
    June: 'Qershor',
    July: 'Korrik',
    August: 'Gusht',
    September: 'Shtator',
    October: 'Tetor',
    November: 'Nëntor',
    December: 'Dhjetor',
    }

    export function formatDate(date) {
    let str = new Date(date).toLocaleString('sq', { day: 'numeric', month: 'long', year: 'numeric' })
    for (const enMonth in month2sq) {
    str = str.replace(enMonth, month2sq[enMonth])
    }

    const m = new Date().toLocaleString('en', { month: 'long' })
    const monthNameSq = isEnglish ? m : month2sq[m]

    return capitalizeEachWord(str)
    }
  2. xardit renamed this gist Jun 19, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. xardit created this gist Jun 19, 2024.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    const month2sq = {
    January: 'Janar',
    February: 'Shkurt',
    March: 'Mars',
    April: 'Prill',
    May: 'Maj',
    June: 'Qershor',
    July: 'Korrik',
    August: 'Gusht',
    September: 'Shtator',
    October: 'Tetor',
    November: 'Nëntor',
    December: 'Dhjetor',
    }

    const m = new Date().toLocaleString('en', { month: 'long' })
    const monthNameSq = isEnglish ? m : month2sq[m]