-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (36 loc) · 1.01 KB
/
server.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
function convert(data)
{
if (data.dateAD)
{
let date = DateBS.fromAD(new Date(data.dateAD));
console.log("converted log from AD "+date.dateAD+" to BS "+ date);
return date;
}
else if (data.dateBS)
{
let date = DateBS.fromString(data.dateBS);
console.log("converted date in BS "+ date + " to AD " + date.toAD());
return date.toAD();
}
else
{
let date = DateBS.fromAD();
console.log("todays date: "+ date);
return date;
}
}
function doGet(request)
{
console.log(request.parameters);
let data = request.parameter;
let date = convert(data);
output = ContentService.createTextOutput(date.toString()).setMimeType(ContentService.MimeType.TEXT);
return output;
}
function doPost(request)
{
let data = JSON.parse(request.postData.contents);
console.log(data);
let date = convert(data);
return ContentService.createTextOutput(JSON.stringify({date:date})).setMimeType(ContentService.MimeType.JSON);
}