Created
October 8, 2024 10:22
-
-
Save adejorosam/fb67b6e10cd867fa5df612f6aa9db904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import * as moment from 'moment-timezone'; | |
isMarketOpen(): boolean { | |
// Define Lagos market hours | |
const marketOpen = { start: '10:00', end: '14:30' }; // 10 AM to 2:30 PM | |
// Get current time in Lagos | |
const lagosTime = moment().tz('Africa/Lagos'); | |
// Check if today is a weekend (Saturday = 6, Sunday = 0) | |
const isWeekend = lagosTime.day() === 6 || lagosTime.day() === 0; | |
if (isWeekend) { | |
return false; | |
} | |
// Check if current time is within Lagos market hours | |
const isLagosMarketOpen = lagosTime.format('HH:mm') >= lagosMarketOpen.start && lagosTime.format('HH:mm') <= lagosMarketOpen.end; | |
return isLagosMarketOpen; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment