npm.io
1.1.3 • Published 5 years ago

@mangar2/time

Licence
LGPL-3.0-or-later
Version
1.1.3
Deps
1
Size
8 kB
Vulns
0
Weekly
0

Abstract

Contents

Meta

Global functions

dateToTimeOfDayInSeconds

dateToTimeOfDayInSeconds (date) => {number}

Gets the seconds since midnight of a date .

dateToTimeOfDayInSeconds Parameters
Name Type Description
date Date date to concider
dateToTimeOfDayInSeconds returns
Type Description
number amount 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
Name Type Description
timeString string delta time
isTimeOfDayString returns
Type Description
boolean true , 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
Name Type Description
timeString string delta time
stringToSeconds throws
Type Description
Error on false date format
stringToSeconds returns
Type Description
number time 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
Name Type Description
timeString string time of day
timeOfDayStringToDate throws
Type Description
Error on false time format
timeOfDayStringToDate returns
Type Description
Date today , hours , minutes , seconds set to the time of day string

Keywords