midday.ahk

Converts 24-hour (military) time string to 12-hour (meridiem) time string and vice versa.


Keywords
ahk, 12h, 24h, meridiem, meridiem-time, military-time, midday-time, ante-meridiem, post-meridiem, time, am-time, pm-time, ampm, midday
License
MIT
Install
npm install midday.ahk@0.1.1

Documentation

midday.ahk

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:

npm install midday.ahk

In your code only export.ahk needs to be included:

#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"

You may also review or copy the library from ./export.ahk on GitHub; #Incude as you would normally when manually downloading.

API

.to12(value)

Converts 24-hour (military) time string to 12-hour (meridiem) time string.

Arguments

time (String): the time string

Returns

time (String): converted 24-hour time string to 12-hour time

Exception

throws an error if the time string is invalid

midday.to24("12:30 AM")
; => "00:30"

.to24(value)

Converts 12-hour (meridiem) time string to 24-hour (military) time string.

Arguments

time (String): the time string

Returns

time (String): converted 24-hour time string to 12-hour time

Exception

throws an error if the time string is invalid

midday.to12("00:30")
; => "12:30 AM"

midday.to12("0030")
; => "12:30 AM"