Skip to content

Commit

Permalink
fix timezone inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
trashmai committed Nov 23, 2018
1 parent 7280bf8 commit 8920204
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cognito-s3-control/lambda/lambda_csv_to_json/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let user_password;

function post_to_api (endpoint_path, json, post_callback) {
let post_options = {
host: "api.camera-trap.tw",
host: "api-dev.camera-trap.tw",
port: '443',
path: endpoint_path,
method: 'POST',
Expand Down Expand Up @@ -159,7 +159,7 @@ exports.handler = (event, context, callback) => {
];

// 讀取 project-metadata 與欄位設定相關的資訊, 包括物種清單、其他啟用欄位與定時測試照片的時間設定測試
post_to_api("/api/project/aggregate", post_aggregate, validate_and_create_json);
post_to_api("/project/aggregate", post_aggregate, validate_and_create_json);

let fullCameraLocation = tag_data.projectTitle + "/" + tag_data.site + "/" + tag_data.subSite + "/" + tag_data.cameraLocation;
let fullCameraLocationMd5 = md5(fullCameraLocation);
Expand Down Expand Up @@ -270,12 +270,12 @@ exports.handler = (event, context, callback) => {
let baseFileNameParts;
let timestamp, corrected_timestamp;

let date_time_obj = new Date(record[field_map.date_time]);
let date_time_obj = new Date(record[field_map.date_time] + '+8');
timestamp = date_time_obj.getTime() / 1000;
//console.log([record[field_map.date_time], timestamp]);

let corrected_date_time = record[field_map.corrected_date_time] ? record[field_map.corrected_date_time] : record[field_map.date_time];
let corrected_date_time_obj = new Date(corrected_date_time);
let corrected_date_time_obj = new Date(corrected_date_time + '+8');
corrected_timestamp = corrected_date_time_obj.getTime() / 1000;


Expand Down Expand Up @@ -494,7 +494,7 @@ exports.handler = (event, context, callback) => {
}

let data_overlap = false;
post_to_api("/api/media/annotation/exists", overlap_range, function(res) {
post_to_api("/media/annotation/exists", overlap_range, function(res) {
console.log(JSON.stringify(overlap_range, null, 2));

if (res.results !== null) {
Expand All @@ -503,7 +503,7 @@ exports.handler = (event, context, callback) => {
}

if (data_errors.length > 0) {
post_to_api("/api/upload-session/bulk-update", [{
post_to_api("/upload-session/bulk-update", [{
_id: upload_session_id,
projectTitle: tag_data.projectTitle,
$set: {
Expand Down Expand Up @@ -532,7 +532,7 @@ exports.handler = (event, context, callback) => {
});
}
else {
post_to_api("/api/upload-session/bulk-update", [{
post_to_api("/upload-session/bulk-update", [{
_id: upload_session_id,
projectTitle: tag_data.projectTitle,
$set: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ exports.handler = (event, context, callback) => {

// data lock api
let lock_post_options = {
host: "api.camera-trap.tw",
host: "api-dev.camera-trap.tw",
port: '443',
path: "/api/camera-location/data-lock/bulk-replace",
path: "/camera-location/data-lock/bulk-replace",
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -96,9 +96,9 @@ exports.handler = (event, context, callback) => {

// An object of options to indicate where to post to
let post_options = {
host: "api.camera-trap.tw",
host: "api-dev.camera-trap.tw",
port: '443',
path: "/api" + json.endpoint,
path: json.endpoint,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports.handler = (event, context, callback) => {
let dateTimeComponents = exifData.exif.DateTimeOriginal.match(/\d+/g);
let dateTimeString = dateTimeComponents[0] + "/" + dateTimeComponents[1] + "/" + dateTimeComponents[2] + " " + dateTimeComponents[3] + ":" + dateTimeComponents[4] + ":" + dateTimeComponents[5];

let date_time_obj = new Date(dateTimeString);
let date_time_obj = new Date(dateTimeString + '+8');
let timestamp = date_time_obj.getTime() / 1000;

let year = date_time_obj.getFullYear();
Expand Down

0 comments on commit 8920204

Please sign in to comment.