Test dates
parent
3fb4f69de3
commit
04457eaca6
|
|
@ -31,12 +31,12 @@ router.get("/page/:page",function(req,res){
|
||||||
}
|
}
|
||||||
if (req.params.page < 2 && events.length < 23){
|
if (req.params.page < 2 && events.length < 23){
|
||||||
var offset = moment.tz.zone("America/Denver").offset(new Date());
|
var offset = moment.tz.zone("America/Denver").offset(new Date());
|
||||||
var nowMountain = moment.tz(new Date(),"Mountain/Denver");
|
var sundaySchool = nextDay(new Date(), 0, 19, offset);
|
||||||
var nextSundayMorning = nextDay(nowMountain, 0, 7);
|
var nextSundayMorning = nextDay(nowMountain, 0, 7);
|
||||||
var nextSundayMorning2 = nextDay(nowMountain, 0, 11);
|
var nextSundayMorning2 = nextDay(nowMountain, 0, 11);
|
||||||
var nextSundayEvening = nextDay(nowMountain, 0, 19);
|
var nextSundayEvening = nextDay(nowMountain, 0, 19);
|
||||||
var nextWednesday = nextDay(nowMountain, 3, 7, 19);
|
var nextWednesday = nextDay(nowMountain, 3, 7, 19);
|
||||||
if (nextWednesday < nextSundayMorning){
|
if (nextWednesday < sundaySchool){
|
||||||
nextWednesday.setHours(19);
|
nextWednesday.setHours(19);
|
||||||
nextWednesday.setMinutes(0);
|
nextWednesday.setMinutes(0);
|
||||||
nextWednesday.setSeconds(0);
|
nextWednesday.setSeconds(0);
|
||||||
|
|
@ -49,8 +49,8 @@ router.get("/page/:page",function(req,res){
|
||||||
}
|
}
|
||||||
events.push({
|
events.push({
|
||||||
title: 'Sunday School ' + offset,
|
title: 'Sunday School ' + offset,
|
||||||
startDate: moment.tz(nextSundayMorning,"America/Denver").format(),
|
startDate: sundaySchool,
|
||||||
endDate: new Date(nextSundayMorning).setHours(11),
|
endDate: new Date(sundaySchool).setHours(11),
|
||||||
description: 'Sunday School Service'
|
description: 'Sunday School Service'
|
||||||
});
|
});
|
||||||
events.push({
|
events.push({
|
||||||
|
|
@ -113,13 +113,14 @@ router.delete("/a/",function(req,res){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function nextDay(startDate, dayOfWeek, hour){
|
function nextDay(startDate, dayOfWeek, hour, offset){
|
||||||
startDate = new Date(startDate);
|
startDate = new Date(startDate);
|
||||||
startDate.setDate(startDate.getDate() + (dayOfWeek+(7-startDate.getDay())) % 7);
|
startDate.setDate(startDate.getDate() + (dayOfWeek+(7-startDate.getDay())) % 7);
|
||||||
startDate.setHours(hour);
|
startDate.setHours(hour);
|
||||||
startDate.setMinutes(0);
|
startDate.setMinutes(0);
|
||||||
startDate.setSeconds(0);
|
startDate.setSeconds(0);
|
||||||
startDate.setMilliseconds(0);
|
startDate.setMilliseconds(0);
|
||||||
|
startDate.setOffset(offst);
|
||||||
return startDate;
|
return startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue