is-x-time
v1.0.1
Published
Returns boolean for various time-of-day queries such as isNight and isBusinessHours
Downloads
4
Maintainers
Readme
is-x-time v1.0.0
Evaluate common time-of-day periods.
Complete list of is-x-time functions
nowHourIn(tz: IANATimeZone): number
nowHourInAWS(awsrc: AWSRegionCode): number
isDayTimeIn(tz: IANATimeZone): boolean
isDayTimeInAWS(awsrc: AWSRegionCode): boolean
isNightTimeIn(tz: IANATimeZone): boolean
isNightTimeInAWS(awsrc: AWSRegionCode): boolean
isNightIn(tz: IANATimeZone): boolean
isNightInAWS(awsrc: AWSRegionCode): boolean
isMorningIn(tz: IANATimeZone): boolean
isMorningInAWS(awsrc: AWSRegionCode): boolean
isAfternoonIn(tz: IANATimeZone): boolean
isAfternoonInAWS(awsrc: AWSRegionCode): boolean
isEveningIn(tz: IANATimeZone): boolean
isEveningInAWS(awsrc: AWSRegionCode): boolean
isBusinessHoursIn(tz: IANATimeZone): boolean
isBusinessHoursInAWS(awsrc: AWSRegionCode): boolean
isDayShiftIn(tz: IANATimeZone): boolean
isDayShiftInAWS(awsrc: AWSRegionCode): boolean
isEveningShiftIn(tz: IANATimeZone): boolean
isEveningShiftInAWS(awsrc: AWSRegionCode): boolean
isNightShiftIn(tz: IANATimeZone): boolean
isNightShiftInAWS(awsrc: AWSRegionCode): boolean
Installation
Using npm:
npm i is-x-time
Size
Usage
// CommonJS
const IsXTime = require('is-x-time');
// ES Modules
// Load full library
import * as IsXTime from "is-x-time";
// Load individual function(s)
import { isAfternoon, isBusinessHours, ... } from "is-x-time";
// Browser ES Modules
<script type="module" src="/path/to/is-x-time.es.js"></script>
<script type="module">
import IsXTime from '/path/to/is-x-time.es.js';
IsXTime.nowHour();
// 0-23
</script>
// Browser UMD
<script type="module" src="/path/to/is-x-time.es.js"></script>
<script nomodule defer src="/path/to/web.is-x-time.js"></script>
Detailed list of is-x-time functions
Current Hour
nowHour()
Returns the current hour number 0 - 23
.
nowHourIn(tz: IANATimeZone)
Returns the current hour number 0 - 23
of the specified IANATimeZone.
nowHourInAWS(awsrc: AWSRegionCode)
Returns the current hour number 0 - 23
of the specified AWS Region Code.
NightTime, DayTime
A calendar day split into two 12 hour periods.
isNightTime()
Time is between 6:00pm
and 5:59am
, inclusive.
Time is between 18:00
and 05:59
, inclusive.
isNightTimeIn(tz: IANATimeZone)
Time is between 6:00pm
and 5:59am
, inclusive, in specified IANATimeZone.
Time is between 18:00
and 05:59
, inclusive, in specified IANATimeZone.
isNightTimeInAWS(awsrc: AWSRegionCode)
Time is between 6:00pm
and 5:59am
, inclusive, in specified AWS Region Code.
Time is between 18:00
and 05:59
, inclusive, in specified AWS Region Code.
isDayTime()
Time is between 6:00am
and 5:59pm
, inclusive.
Time is between 06:00
and 17:59
, inclusive.
isDayTimeIn(tz: IANATimeZone)
Time is between 6:00am
and 5:59pm
, inclusive, in specified IANATimeZone.
Time is between 06:00
and 17:59
, inclusive, in specified IANATimeZone.
isDayTimeInAWS(awsrc: AWSRegionCode)
Time is between 6:00am
and 5:59pm
, inclusive, in specified AWS Region Code.
Time is between 06:00
and 17:59
, inclusive, in specified AWS Region Code.
Night, Morning, Afternoon, Evening
A calendar day split into four 6 hour periods.
isNight()
Time is between 0:00am
and 5:59am
, inclusive.
Time is between 00:00
and 05:59
, inclusive.
isNightIn(tz: IANATimeZone)
Time is between 0:00am
and 5:59am
, inclusive, in specified IANATimeZone.
Time is between 00:00
and 05:59
, inclusive, in specified IANATimeZone.
isNightInAWS(awsrc: AWSRegionCode)
Time is between 0:00am
and 5:59am
, inclusive, in specified AWS Region Code.
Time is between 00:00
and 05:59
, inclusive, in specified AWS Region Code.
isMorning()
Time is between 6:00am
and 11:59am
, inclusive.
Time is between 06:00
and 11:59
, inclusive.
isMorningIn(tz: IANATimeZone)
Time is between 6:00am
and 11:59am
, inclusive, in specified IANATimeZone.
Time is between 06:00
and 11:59
, inclusive, in specified IANATimeZone.
isMorningInAWS(awsrc: AWSRegionCode)
Time is between 6:00am
and 11:59am
, inclusive, in specified AWS Region Code.
Time is between 06:00
and 11:59
, inclusive, in specified AWS Region Code.
isAfternoon()
Time is between 12:00pm
and 5:59pm
, inclusive.
Time is between 12:00
and 17:59
, inclusive.
isAfternoonIn(tz: IANATimeZone)
Time is between 12:00pm
and 5:59pm
, inclusive, in specified IANATimeZone.
Time is between 12:00
and 17:59
, inclusive, in specified IANATimeZone.
isAfternoonInAWS(awsrc: AWSRegionCode)
Time is between 12:00pm
and 5:59pm
, inclusive, in specified AWS Region Code.
Time is between 12:00
and 17:59
, inclusive, in specified AWS Region Code.
isEvening()
Time is between 6:00pm
and 11:59pm
, inclusive.
Time is between 18:00
and 23:59
, inclusive.
isEveningIn(tz: IANATimeZone)
Time is between 6:00pm
and 11:59pm
, inclusive, in specified IANATimeZone.
Time is between 18:00
and 23:59
, inclusive, in specified IANATimeZone.
isEveningInAWS(awsrc: AWSRegionCode)
Time is between 6:00pm
and 11:59pm
, inclusive, in specified AWS Region Code.
Time is between 18:00
and 23:59
, inclusive, in specified AWS Region Code.
Business Hours (9 2 5)
isBusinessHours()
Time is between 9:00am
and 4:59pm
, inclusive.
Time is between 09:00
and 16:59
, inclusive.
isBusinessHoursIn(tz: IANATimeZone)
Time is between 9:00am
and 4:59pm
, inclusive, in specified IANATimeZone.
Time is between 09:00
and 16:59
, inclusive, in specified IANATimeZone.
isBusinessHoursInAWS(awsrc: AWSRegionCode)
Time is between 9:00am
and 4:59pm
, inclusive, in specified AWS Region Code.
Time is between 09:00
and 16:59
, inclusive, in specified AWS Region Code.
DayShift, EveningShift, NightShift
A calendar day split into three 8 hour periods.
isNightShift()
Time is between 0:00am
and 7:59am
, inclusive.
Time is between 00:00
and 07:59
, inclusive.
isNightShiftIn(tz: IANATimeZone)
Time is between 0:00am
and 7:59am
, inclusive, in specified IANATimeZone.
Time is between 00:00
and 07:59
, inclusive, in specified IANATimeZone.
isNightShiftInAWS(awsrc: AWSRegionCode)
Time is between 0:00am
and 7:59am
, inclusive, in specified AWS Region Code.
Time is between 00:00
and 07:59
, inclusive, in specified AWS Region Code.
isDayShift()
Time is between 8:00am
and 3:59pm
, inclusive.
Time is between 08:00
and 15:59
, inclusive.
isDayShiftIn(tz: IANATimeZone)
Time is between 8:00am
and 3:59pm
, inclusive, in specified IANATimeZone.
Time is between 08:00
and 15:59
, inclusive, in specified IANATimeZone.
isDayShiftInAWS(awsrc: AWSRegionCode)
Time is between 8:00am
and 3:59pm
, inclusive, in specified AWS Region Code.
Time is between 08:00
and 15:59
, inclusive, in specified AWS Region Code.
isEveningShift()
Time is between 4:00pm
and 11:59pm
, inclusive.
Time is between 16:00
and 23:59
, inclusive.
isEveningShiftIn(tz: IANATimeZone)
Time is between 4:00pm
and 11:59pm
, inclusive, in specified IANATimeZone.
Time is between 16:00
and 23:59
, inclusive, in specified IANATimeZone.
isEveningShiftInAWS(awsrc: AWSRegionCode)
Time is between 4:00pm
and 11:59pm
, inclusive, in specified AWS Region Code.
Time is between 16:00
and 23:59
, inclusive, in specified AWS Region Code.