var sunset = prompt(\”Enter sunset time (HH:MM 24-hour format):\”);\nvar civilTwilight = prompt(\”Enter civil twilight end time (HH:MM 24-hour format):\”);\n\nif (sunset && civilTwilight) {\n // Parse times\n var sunsetTime = new Date(\”2000-01-01T\” + sunset + \”:00\”);\n var civilTwilightTime = new Date(\”2000-01-01T\” + civilTwilight + \”:00\”);\n \n // Calculate duration\n var durationMs = sunsetTime – civilTwilightTime;\n var durationMinutes = Math.floor(durationMs / (1000 * 60));\n \n // Calculate last third\n var lastThirdMs = durationMinutes / 3 * 1000;\n var lastThirdEnd = new Date(civilTwilightTime.getTime() + lastThirdMs);\n \n // Format output\n var formatTime = function(date) {\n var hours = date.getHours();\n var minutes = date.getMinutes();\n var ampm = hours >= 12 ? ‘pm’ : ‘am’;\n hours = hours % 12;\n hours = hours ? hours : 12; // the hour ‘0’ should be ’12’\n minutes = minutes < 10 ? '0' + minutes : minutes;\n return hours + ':' + minutes + ' ' + ampm;\n };\n \n var durationFormatted = Math.floor(durationMinutes / 60) + 'h ' + (durationMinutes % 60) + 'm';\n var lastThirdFormatted = formatTime(lastThirdEnd);\n \n alert(\"Duration between sunset and civil twilight: \" + durationFormatted + \". The last third of this period ends at: \" + lastThirdFormatted);\n} else {\n alert(\"Please provide both sunset and civil twilight times.\");\n}\n\n"
}
]
}
\n\n
Calculate Last Third of Night
\n \n
This tool calculates the end of the last third of the night, which is a period used in Halakha (Jewish law) for specific time-based commandments.
\n \n
\n \n
\n \n
\n \n
\n \n \n
\n
\n\n