Pacific Standard Time is UTC-0800, however everywhere that uses PST also observes daylight saving so just converting to PST may not be sufficient.
Anyway, as pretzelhammer suggests you can convert the PST times to UTC to create suitable Date objects, then compare with those. Note that 21:00 PST is 05:00 UTC the next day, but that's not really a problem. You can set the start time as 13:00 UTC then just add 16 hours Monday to Friday, or 12.5 hours on Saturday and Sunday.
To get the right start date, if it's before 08:00 UTC, change the UTC date to the previous day and the time to 05:00. Then depending on whether it's a week day or week end, the finish is set by adding the open duration.
// M-F 05:00 - 21:00 PST -> 13:00 - 05:00 UTC
// Sa-Su 05:00 - 17:30 PST -> 13:00 - 01:30 UTC
function getRange(date) {
// Start is 1300 UTC every day
var start = new Date(date);
// If before 0800 UTC, set to previous day
if (start.getUTCHours() < 8) {
start.setDate(start.getDate() - 1);
}
start.setUTCHours(13,0,0,0);
// Set end to +16 or +12.5 hours if weekend
var end = new Date(start);
if (end.getDay() % 6) {
end.setHours(end.getHours() + 16);
} else {
end.setHours(end.getHours() + 12, 30);
}
return [start, end];
}
function isInRange(date) {
date = date || new Date();
var range = getRange(date);
return date >= range[0] && date <= range[1];
}
// Helper to get current time PST (UTC-0800)
function getPSTTime(date) {
date = date || new Date();
function z(n){return (n<10?'0':'')+n}
var d = new Date(date);
d.setUTCHours(d.getUTCHours()-8);
return 'Sun Mon Tue Wed Thu Fri Sat'.split(' ' )[d.getUTCDay()] + ' ' + z(d.getUTCHours()) + ':' + z(d.getUTCMinutes());
}
// Is the current time in range?
var d = new Date();
console.log('PST Time: ' + getPSTTime());
console.log('Is it in range? ' + (isInRange(d)? 'yes':'no'));