Skip to content

Instantly share code, notes, and snippets.

@annahri
Created July 14, 2020 02:35
Show Gist options
  • Save annahri/b28e2e2da21ea64fb5dc78273acb32b9 to your computer and use it in GitHub Desktop.
Save annahri/b28e2e2da21ea64fb5dc78273acb32b9 to your computer and use it in GitHub Desktop.
Menampilkan tanggal hari ini dalam penanggalan hijriyah.
#! /usr/bin/env bash
tanggal="$1"
tanggal="${tanggal:-$(date +'%Y-%m-%d')}"
hijri=$(python3 - <<CMD
from ummalqura.hijri_date import HijriDate
from datetime import date
print(HijriDate.get_hijri_date("$tanggal"))
CMD
)
tahun=`cut -d- -f1 <<<"$hijri"`
bulan=`cut -d- -f2 <<<"$hijri"`
hari=`cut -d- -f3 <<<"$hijri"`
declare -a hijriah=(
"Muharram"
"Safar"
"Rabi'ul Awwal"
"Rabi'ut Tsani"
"Jumadil Ula"
"Jumadil Akhir"
"Rajab"
"Sya'ban"
"Ramadhan"
"Syawwal"
"Dzulqa'dah"
"Dzulhijjah"
)
bulan="${hijriah[`echo "$bulan - 1" | bc`]}"
echo "$hari $bulan $tahun"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment