Converts 24-hour (military) time string to 12-hour (meridiem) time string and vice versa.
Installation
In a terminal or command line navigated to your project folder:
Code: Select all
npm install midday.ahk
Code: Select all
#Include %A_ScriptDir%\node_modules
#Include midday.ahk\export.ahk
midday := new midday()
result := midday.to24("12:30 AM")
; => "00:30"
result := midday.to12("00:30")
; => "12:30 AM"
API
Including the module provides a class midday with two methods: .to12 and .to24
to12(value)
Converts 24-hour (military) time string to 12-hour (meridiem) time string.
Arguments
value (String): the time string
Returns
(String): converted 24-hour time string to 12-hour time
Exceptions
throws an error if the time string is invalid
Example
Code: Select all
midday.to24("12:30 AM")
; => "00:30"
.to24(value)
Converts 12-hour (meridiem) time string to 24-hour (military) time string.
Arguments
value (String): the time string
Returns
(String): converted 24-hour time string to 12-hour time
Exceptions
throws an error if the time string is invalid
Examples
Code: Select all
midday.to12("00:30")
; => "12:30 AM"
midday.to12("0030")
; => "12:30 AM"
Meta Tags: meridiem, meridiem-time, military-time, midday-time, ante-meridiem, post-meridiem, am-time, pm-time