-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatesamp.js
39 lines (34 loc) · 996 Bytes
/
datesamp.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
function time_solver(input_dictionary){
var datestamp = input_dictionary.datestamp
var interval = input_dictionary.interval
var d = new Date(datestamp);
var n_d = new Date(d.getTime() + interval*1000);
return n_d.toISOString().substring(0,19) + n_d.toISOString()[23];
};
$(document).ready(function() {
var input_dictionary;
$.ajax({
method: "post",
url: "http://challenge.code2040.org/api/dating",
contentType: "application/json",
data: JSON.stringify({
token: "9bda8ddfccaecd94037ff799077d4870"
}),
success: function(data){
input_dictionary = data;
$.ajax({
method: "post",
contentType: "application/json",
url: "http://challenge.code2040.org/api/dating/validate",
dataType: 'json',
data: JSON.stringify({
token: "9bda8ddfccaecd94037ff799077d4870",
datestamp: time_solver(input_dictionary)
})
});
},
error: function(data) {
console.log(data);
}
});
});