-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.js
109 lines (98 loc) · 2.94 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//const data = require("./data");
const dataPrayers = require("./db_prayers");
const dataStations = require("./db_stations_of_cross");
const dataSaintOfTheDay = require("./db_saint_of_the_day");
const dataSaintDuJour = require("./db_saint_du_jour");
//const dataSaints = require("./saints_en");
//const dataSaintsFr = require("./saints_fr");
//
// Logic behind the functionalities
var serverTime = "America/New_York"; // America/New_York /
// current datetime string inAmerica/New_York timezone
let local_datetime_str = new Date().toLocaleString("en-US", {
timeZone: serverTime
});
// create new Date object
//let date_local = new Date(local_datetime_str);
let d = new Date(local_datetime_str);
// Months
let allMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let monthTxt = allMonths[d.getMonth()]; // May
// year as (YYYY) format
let year = d.getFullYear();
// month as (MM) format
//let month = ("0" + (d.getMonth() + 1)).slice(-2);
let month = d.getMonth() + 1;
// date as (DD) format
//let date = ("0" + d.getDate()).slice(-2);
let date = d.getDate();
// date as (D) format
//let d_dd = d.getDate();
// date time in YYYY-MM-DD format
let today = month + "/" + date;
// "1/1"
console.log(today);
//
//let todayfull = monthTxt +' '+ d_dd +', '+ year; // -> May 18, 2022
//console.log(todayfull);
//
class Controller {
// getting all dataPrayers
async getAllData() {
// return all dataPrayers
return new Promise((resolve, _) => resolve(dataPrayers));
}
// getting Stations of the cross
async getStationData() {
// return all dataPrayers
return new Promise((resolve, _) => resolve(dataStations));
}
// getting all the saints
async getSaintsData() {
// return all dataPrayers
return new Promise((resolve, _) => resolve(dataSaintOfTheDay));
}
// getting Stations of the cross
async getSaintsFrData() {
// return all dataPrayers
return new Promise((resolve, _) => resolve(dataSaintDuJour));
}
// getting today data
async getTodaySaintData() {
return new Promise((resolve, reject) => {
// get the data
let todayData = dataSaintOfTheDay.filter(function(todayIn) {
return todayIn.saint_date == today;
});
// console.log(todayData);
if (todayData) {
// return the data
resolve(todayData);
} else {
// return an error
reject(`Today object not found `);
}
});
}
//
// getting today data French
async getTodaySaintDataFr() {
return new Promise((resolve, reject) => {
// get the data
let todayData = dataSaintDuJour.filter(function(todayIn) {
return todayIn.saint_date == today;
});
// console.log(todayData);
if (todayData) {
// return the data
resolve(todayData);
} else {
// return an error
reject(`Today object not found `);
}
});
}
//
// add below
}
module.exports = Controller;