1.1.3 • Published 3 years ago

@mangar2/time v1.1.3

Weekly downloads
5
License
LGPL-3.0-or-later
Repository
github
Last release
3 years ago

Abstract

Contents

Meta

Global functions

dateToTimeOfDayInSeconds

dateToTimeOfDayInSeconds (date) => {number}

Gets the seconds since midnight of a date .

dateToTimeOfDayInSeconds Parameters

NameTypeDescription
dateDatedate to concider

dateToTimeOfDayInSeconds returns

TypeDescription
numberamount of seconds passed since midnight

isTimeOfDayString

isTimeOfDayString (timeString) => {boolean}

Checks , if a string is a time of day string ( HH : MM or HH : MM : SS )

isTimeOfDayString Parameters

NameTypeDescription
timeStringstringdelta time

isTimeOfDayString returns

TypeDescription
booleantrue , if the string is a time of day string

stringToSeconds

stringToSeconds (timeString) => {number}

Converts a time string in format HH : MM or HH : MM : SS or MMM to seconds

stringToSeconds Parameters

NameTypeDescription
timeStringstringdelta time

stringToSeconds throws

TypeDescription
Erroron false date format

stringToSeconds returns

TypeDescription
numbertime string in seconds

timeOfDayStringToDate

timeOfDayStringToDate (timeString) => {Date}

Converts a time string in format HH : MM or HH : MM : SS or MMM to a date ( today , same time of day )

timeOfDayStringToDate Parameters

NameTypeDescription
timeStringstringtime of day

timeOfDayStringToDate throws

TypeDescription
Erroron false time format

timeOfDayStringToDate returns

TypeDescription
Datetoday , hours , minutes , seconds set to the time of day string