UNPKG

ng-timeparser

Version:

[![npm version](https://badge.fury.io/js/ng-timeparser.svg)](https://badge.fury.io/js/ng-timeparser) [![Build Status](https://travis-ci.org/feeloor/ng-timeparser.svg?branch=master)](https://travis-ci.org/feeloor/ng-timeparser)

29 lines (28 loc) 1.01 kB
export declare class TimeParserService { constructor(); /** * Parses given time-string to a correct 4 digit time or empty if it's an invalid time * @param inputTime Time-string to parse * @param militaryTime Use military time (24 hour format) */ parseTime(inputTime: string, militaryTime?: boolean): string; /** * Parses a valid time to a 4 digit time * For example 4 PM to 04:00 PM or 4:30 PM to 04:30 PM * @param time Time-string to parse to 4 digit */ private makeTime4Digit(time); /** * Adds a colon if it's missing to given time-string * For example 0400 to 04:00 * @param time Time-string to add missing colon to */ private addColonIfMissing(time); /** * Takes start and end of time-string and then adds correct AM/PM * @param time Time-string to add AM or PM too * @param start Where time starts in string * @param end Where time ends in string */ private addAMorPM(time, start, end); }