Skip to content

Instantly share code, notes, and snippets.

@ebraminio
Last active May 28, 2021 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebraminio/b87ced9d32365ca3cddfd4af86cc934a to your computer and use it in GitHub Desktop.
Save ebraminio/b87ced9d32365ca3cddfd4af86cc934a to your computer and use it in GitHub Desktop.
Persian Calendar related calculations, install https://github.com/Kotlin/kotlin-jupyter first
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "901e6abd",
"metadata": {},
"outputs": [],
"source": [
"@file:Repository(\"https://jitpack.io\")\n",
"@file:DependsOn(\"com.github.persian-calendar:equinox:1.0.0\")\n",
"@file:DependsOn(\"com.github.persian-calendar:calendar:1.0.1\")\n",
"@file:DependsOn(\"com.github.persian-calendar:praytimes:1.0.2\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d9023c0e",
"metadata": {},
"outputs": [],
"source": [
"import io.github.persiancalendar.*\n",
"import io.github.persiancalendar.calendar.*\n",
"import io.github.persiancalendar.calendar.islamic.*\n",
"import io.github.persiancalendar.praytimes.*"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "85ff92b7",
"metadata": {},
"outputs": [],
"source": [
"import java.util.*"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "779cd8f4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Sat Mar 20 13:07:14 IRST 2021"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Equinox.northwardEquinox(2021)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bdb591ef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[4:44, 6:08, 12:13, 18:19, 18:37, 23:32]\n",
"[5:43, 7:07, 13:13, 19:20, 19:38, 0:31]\n",
"[5:41, 7:06, 13:13, 19:20, 19:38, 0:31]\n",
"[5:40, 7:04, 13:12, 19:21, 19:39, 0:31]\n",
"[5:38, 7:03, 13:12, 19:22, 19:40, 0:30]\n",
"[5:37, 7:01, 13:12, 19:23, 19:41, 0:30]\n",
"[5:35, 7:00, 13:11, 19:24, 19:42, 0:29]\n",
"[5:34, 6:58, 13:11, 19:25, 19:43, 0:29]\n",
"[5:32, 6:57, 13:11, 19:25, 19:44, 0:29]\n",
"[5:30, 6:55, 13:11, 19:26, 19:44, 0:28]\n",
"[5:29, 6:54, 13:10, 19:27, 19:45, 0:28]\n",
"[5:27, 6:53, 13:10, 19:28, 19:46, 0:28]\n",
"[5:26, 6:51, 13:10, 19:29, 19:47, 0:27]\n",
"[5:24, 6:50, 13:09, 19:30, 19:48, 0:27]\n",
"[5:22, 6:48, 13:09, 19:30, 19:49, 0:26]\n",
"[5:21, 6:47, 13:09, 19:31, 19:50, 0:26]\n",
"[5:19, 6:46, 13:09, 19:32, 19:50, 0:26]\n",
"[5:18, 6:44, 13:08, 19:33, 19:51, 0:25]\n",
"[5:16, 6:43, 13:08, 19:34, 19:52, 0:25]\n",
"[5:14, 6:41, 13:08, 19:34, 19:53, 0:24]\n",
"[5:13, 6:40, 13:07, 19:35, 19:54, 0:24]\n",
"[5:11, 6:39, 13:07, 19:36, 19:55, 0:24]\n",
"[5:10, 6:37, 13:07, 19:37, 19:56, 0:23]\n",
"[5:08, 6:36, 13:07, 19:38, 19:56, 0:23]\n",
"[5:06, 6:35, 13:06, 19:39, 19:57, 0:23]\n",
"[5:05, 6:33, 13:06, 19:39, 19:58, 0:22]\n",
"[5:03, 6:32, 13:06, 19:40, 19:59, 0:22]\n",
"[5:02, 6:31, 13:06, 19:41, 20:00, 0:21]\n",
"[5:00, 6:29, 13:05, 19:42, 20:01, 0:21]\n",
"[4:59, 6:28, 13:05, 19:43, 20:02, 0:21]\n",
"[4:57, 6:27, 13:05, 19:44, 20:03, 0:20]\n",
"[4:55, 6:26, 13:05, 19:45, 20:03, 0:20]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val coordinate = Coordinate(35.82, 50.97, .0)\n",
"val jdn = PersianDate(1400, 1, 1).toJdn()\n",
"\n",
"(jdn..jdn + 31).map { it ->\n",
" val date = Date(CivilDate(it).let {\n",
" Calendar.getInstance().apply { set(it.year, it.month - 1, it.dayOfMonth) }\n",
" }.timeInMillis)\n",
"\n",
" PrayTimesCalculator.calculate(CalculationMethod.Tehran, date, coordinate).let {\n",
" listOf(it.fajrClock, it.sunriseClock, it.dhuhrClock, it.sunsetClock, it.maghribClock, it.midnightClock)\n",
" }.map { \"${it.hour}:${it.minute.toString().padStart(2, '0')}\" }\n",
"}.joinToString(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c8fba1ad",
"metadata": {},
"outputs": [],
"source": [
"@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "5b2e7191",
"metadata": {},
"outputs": [],
"source": [
"import kotlinx.coroutines.*\n",
"import kotlinx.coroutines.flow.*"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "fc6907b3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n",
"4\n",
"2\n"
]
},
{
"data": {
"text/plain": [
"StandaloneCoroutine{Completed}@3153ddfc"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"flowOf(3, 4, 2).onEach { println(it) }.launchIn(CoroutineScope(Dispatchers.Default))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "confused-price",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29]\n",
"[30, 29, 30, 29, 30, 29, 29, 30, 30, 29, 30, 29]\n",
"[30, 30, 30, 58, 30, 29, 29, 30, 29, 30, 29, 30]\n",
"[30, 30, 30]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val text = \"\"\"\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░ tehran 35:40N 51:26E TZ:+3.5 Ht:0m ░\n",
"░ LOCAL HIJRI CALENDAR BASED ON PREDICTED CRESCENT VISIBILITY ░\n",
"░ ░\n",
"░ Hijri month Greogorian date Hijri Day Islamic Lunation ░\n",
"░ ░\n",
"░ 1 Jumad Al-Ula 1441 AH 28 Dec 2019 510407 17285 ░\n",
"░ 1 Jumad Al-Thani 1441 AH 27 Jan 2020 510437 17286 ░\n",
"░ 1 Rajab 1441 AH 26 Feb 2020 510467 17287 ░\n",
"░ 1 Shaban 1441 AH 26 Mar 2020 510496 17288 ░\n",
"░ 1 Ramadhan 1441 AH 25 Apr 2020 510526 17289 ░\n",
"░ 1 Shawwal 1441 AH 25 May 2020 510556 17290 ░\n",
"░ 1 Zul-Qida 1441 AH 23 June 2020 510585 17291 ░\n",
"░ 1 Zul-Hijja 1441 AH 22 July 2020 510614 17292 ░\n",
"░ 1 Muharram 1442 AH 21 Aug 2020 510644 17293 ░\n",
"░ 1 Safar 1442 AH 19 Sep 2020 510673 17294 ░\n",
"░ 1 Rabi Al-Awal 1442 AH 19 Oct 2020 510703 17295 ░\n",
"░ 1 Rabi Al-Thani 1442 AH 17 Nov 2020 510732 17296 ░\n",
"░ ░\n",
"░ 1st day of Hijri months end at sunset on Gregorian dates shown. ░\n",
"░ Criterion: Yallop/-5 [A or B] ░\n",
"░ ░\n",
"░ ░\n",
"░ [M]ore, Space: Menu Data from MoonCalc 6.0, (c) Monzur Ahmed ░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░ tehran 35:40N 51:26E TZ:+3.5 Ht:0m ░\n",
"░ LOCAL HIJRI CALENDAR BASED ON PREDICTED CRESCENT VISIBILITY ░\n",
"░ ░\n",
"░ Hijri month Greogorian date Hijri Day Islamic Lunation ░\n",
"░ ░\n",
"░ 1 Jumad Al-Ula 1442 AH 17 Dec 2020 510762 17297 ░\n",
"░ 1 Jumad Al-Thani 1442 AH 15 Jan 2021 510791 17298 ░\n",
"░ 1 Rajab 1442 AH 14 Feb 2021 510821 17299 ░\n",
"░ 1 Shaban 1442 AH 15 Mar 2021 510850 17300 ░\n",
"░ 1 Ramadhan 1442 AH 14 Apr 2021 510880 17301 ░\n",
"░ 1 Shawwal 1442 AH 14 May 2021 510910 17302 ░\n",
"░ 1 Zul-Qida 1442 AH 12 June 2021 510939 17303 ░\n",
"░ 1 Zul-Hijja 1442 AH 12 July 2021 510969 17304 ░\n",
"░ 1 Muharram 1443 AH 10 Aug 2021 510998 17305 ░\n",
"░ 1 Safar 1443 AH 9 Sep 2021 511028 17306 ░\n",
"░ 1 Rabi Al-Awal 1443 AH 8 Oct 2021 511057 17307 ░\n",
"░ 1 Rabi Al-Thani 1443 AH 7 Nov 2021 511087 17308 ░\n",
"░ ░\n",
"░ 1st day of Hijri months end at sunset on Gregorian dates shown. ░\n",
"░ Criterion: Yallop/-5 [A or B] ░\n",
"░ ░\n",
"░ ░\n",
"░ [M]ore, Space: Menu Data from MoonCalc 6.0, (c) Monzur Ahmed ░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░ tehran 35:40N 51:26E TZ:+3.5 Ht:0m ░\n",
"░ LOCAL HIJRI CALENDAR BASED ON PREDICTED CRESCENT VISIBILITY ░\n",
"░ ░\n",
"░ Hijri month Greogorian date Hijri Day Islamic Lunation ░\n",
"░ ░\n",
"░ 1 Jumad Al-Ula 1443 AH 6 Dec 2021 511116 17309 ░\n",
"░ 1 Jumad Al-Thani 1443 AH 5 Jan 2022 511146 17310 ░\n",
"░ 1 Rajab 1443 AH 3 Feb 2022 511175 17311 ░\n",
"░ 1 Shaban 1443 AH 4 Mar 2022 511204 17312 ░\n",
"░ 1 Ramadhan 1443 AH 3 Apr 2022 511234 17313 ░\n",
"░ 1 Shawwal 1443 AH 3 May 2022 511264 17314 ░\n",
"░ 1 Zul-Qida 1443 AH 1 June 2022 511293 17315 ░\n",
"░ 1 Zul-Hijja 1443 AH 1 July 2022 511323 17316 ░\n",
"░ 1 Muharram 1444 AH 30 July 2022 511352 17317 ░\n",
"░ 1 Safar 1444 AH 29 Aug 2022 511382 17318 ░\n",
"░ 1 Rabi Al-Awal 1444 AH 28 Sep 2022 511412 17319 ░\n",
"░ 1 Rabi Al-Thani 1444 AH 28 Oct 2022 511442 17320 ░\n",
"░ ░\n",
"░ 1st day of Hijri months end at sunset on Gregorian dates shown. ░\n",
"░ Criterion: Yallop/-5 [A or B] ░\n",
"░ ░\n",
"░ ░\n",
"░ [M]ore, Space: Menu Data from MoonCalc 6.0, (c) Monzur Ahmed ░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"░ tehran 35:40N 51:26E TZ:+3.5 Ht:0m ░\n",
"░ LOCAL HIJRI CALENDAR BASED ON PREDICTED CRESCENT VISIBILITY ░\n",
"░ ░\n",
"░ Hijri month Greogorian date Hijri Day Islamic Lunation ░\n",
"░ ░\n",
"░ 1 Jumad Al-Thani 1444 AH 25 Dec 2022 511500 17322 ░\n",
"░ 1 Rajab 1444 AH 24 Jan 2023 511530 17323 ░\n",
"░ 1 Shaban 1444 AH 22 Feb 2023 511559 17324 ░\n",
"░ 1 Ramadhan 1444 AH 23 Mar 2023 511588 17325 ░\n",
"░ 1 Shawwal 1444 AH 22 Apr 2023 511618 17326 ░\n",
"░ 1 Zul-Qida 1444 AH 21 May 2023 511647 17327 ░\n",
"░ 1 Zul-Hijja 1444 AH 20 June 2023 511677 17328 ░\n",
"░ 1 Muharram 1445 AH 19 July 2023 511706 17329 ░\n",
"░ 1 Safar 1445 AH 18 Aug 2023 511736 17330 ░\n",
"░ 1 Rabi Al-Awal 1445 AH 17 Sep 2023 511766 17331 ░\n",
"░ 1 Rabi Al-Thani 1445 AH 17 Oct 2023 511796 17332 ░\n",
"░ 1 Jumad Al-Ula 1445 AH 16 Nov 2023 511826 17333 ░\n",
"░ ░\n",
"░ 1st day of Hijri months end at sunset on Gregorian dates shown. ░\n",
"░ Criterion: Yallop/-5 [A or B] ░\n",
"░ ░\n",
"░ ░\n",
"░ [M]ore, Space: Menu Data from MoonCalc 6.0, (c) Monzur Ahmed ░\n",
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",
"\n",
"\"\"\"\n",
"val days = Regex(\" (51\\\\d+)\").findAll(text).toList().map { it.value.trim().toInt() }.drop(8)\n",
"days.drop(1).mapIndexed { i, x -> x - days[i] }.chunked(12).joinToString(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "certified-marathon",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1427, [30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1428, [29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29])\n",
"(1429, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30])\n",
"(1430, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1431, [29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29])\n",
"(1432, [30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30])\n",
"(1433, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1434, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29])\n",
"(1435, [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30])\n",
"(1436, [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29])\n",
"(1437, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29])\n",
"(1438, [30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1439, [29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29])\n",
"(1440, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30])\n",
"(1441, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1442, [29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29])\n",
"(1443, [30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val daysList = (0..12 * (1444 - 1427)).map { (((1427.0 - 1) * 12 + it) * 29.530588 + 6).roundToInt() }\n",
"daysList.drop(1).mapIndexed { i, x -> x - daysList[i] }\n",
" .chunked(12).mapIndexed { i, x -> 1427 + i to x }.joinToString(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "aquatic-universe",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"29.5305875"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"354.36705 / 12"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "revolutionary-rugby",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2451545"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CivilDate(2000, 1, 1).toJdn()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "horizontal-range",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"29.5305888531"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val T = (CivilDate(2000, 1, 1).toJdn() - 2_451_545) / 36_525\n",
"val S = 29.5305888531 + 0.00000021621 * T - 3.64E-10 * T*T\n",
"S"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "moving-bibliography",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1427, [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30])\n",
"(1428, [29, 29, 30, 29, 30, 29, 29, 30, 30, 29, 30, 30])\n",
"(1429, [30, 29, 30, 29, 29, 29, 30, 29, 30, 29, 30, 30])\n",
"(1430, [30, 29, 30, 30, 29, 29, 29, 30, 29, 30, 29, 30])\n",
"(1431, [30, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29])\n",
"(1432, [30, 29, 30, 30, 30, 29, 30, 29, 30, 29, 29, 30])\n",
"(1433, [29, 30, 29, 30, 30, 29, 30, 30, 29, 29, 30, 29])\n",
"(1434, [30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30])\n",
"(1435, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29])\n",
"(1436, [30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 30, 29])\n",
"(1437, [30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29])\n",
"(1438, [30, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30])\n",
"(1439, [29, 30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29])\n",
"(1440, [30, 29, 30, 29, 30, 30, 30, 29, 30, 29, 30, 29])\n",
"(1441, [29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 29])\n",
"(1442, [30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30])\n",
"(1443, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1444, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val daysList = (1427..1444).flatMap { y -> \n",
" (1..12).map { m ->\n",
" io.github.persiancalendar.calendar.islamic.FallbackIslamicConverter.toJdn(y, m, 1)\n",
" }\n",
"}\n",
"daysList.drop(1).mapIndexed { i, x -> x - daysList[i] }\n",
" .chunked(12).mapIndexed { i, x -> 1427 + i to x }.joinToString(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "stock-bosnia",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1427, [29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29])\n",
"(1428, [30, 29, 29, 30, 29, 29, 30, 30, 30, 29, 30, 30])\n",
"(1429, [29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30])\n",
"(1430, [29, 30, 30, 29, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1431, [29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29, 30])\n",
"(1432, [29, 30, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29])\n",
"(1433, [30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29])\n",
"(1434, [29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 29])\n",
"(1435, [30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30])\n",
"(1436, [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30])\n",
"(1437, [30, 29, 30, 30, 29, 29, 30, 29, 30, 29, 29, 30])\n",
"(1438, [30, 29, 30, 30, 30, 29, 29, 30, 29, 29, 30, 29])\n",
"(1439, [30, 29, 30, 30, 30, 29, 30, 29, 30, 29, 29, 30])\n",
"(1440, [29, 30, 29, 30, 30, 30, 29, 30, 29, 30, 29, 29])\n",
"(1441, [30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29])\n",
"(1442, [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29])\n",
"(1443, [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30])\n",
"(1444, [29, 30, 29, 30, 30, 29, 29, 30, 29, 30, 29])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val daysList = (1427..1444).flatMap { y -> \n",
" (1..12).map { m ->\n",
" java.time.chrono.HijrahChronology.INSTANCE.date(java.time.chrono.HijrahEra.AH, y, m, 1).toEpochDay()\n",
" }\n",
"}\n",
"daysList.drop(1).mapIndexed { i, x -> x - daysList[i] }\n",
" .chunked(12).mapIndexed { i, x -> 1427 + i to x }.joinToString(\"\\n\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.5.30-dev-598"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment