oneday-core
Advanced tools
Comparing version 1.0.55 to 1.0.56
@@ -103,3 +103,3 @@ const aws = require('aws-sdk'); | ||
async function create(params, isPublish = true, topicName = process.env.eventTopic) { | ||
const now = new Date().toISOString(); | ||
const now = util.now(); | ||
params.Item.created = now; | ||
@@ -127,3 +127,3 @@ params.Item.modified = now; | ||
async function update(params, isPublish = true, topicName = process.env.eventTopic) { | ||
const now = new Date().toISOString(); | ||
const now = util.now(); | ||
const expr = params.UpdateExpression; | ||
@@ -153,3 +153,3 @@ | ||
async function softDelete(params, isPublish = true, topicName = process.env.eventTopic) { | ||
const now = new Date().toISOString(); | ||
const now = util.now(); | ||
const expr = params.UpdateExpression; | ||
@@ -156,0 +156,0 @@ |
@@ -43,2 +43,3 @@ 'use strict'; | ||
module.exports.aggregateByProperty = util.aggregateByProperty; | ||
module.exports.now = util.now; | ||
@@ -62,3 +63,3 @@ module.exports.ValidationError = error.ValidationError; | ||
event: event, | ||
created: new Date().toISOString() | ||
created: util.now() | ||
}, | ||
@@ -81,3 +82,3 @@ }; | ||
responseCode: error.statusCode, | ||
created: new Date().toISOString() | ||
created: util.now() | ||
} | ||
@@ -84,0 +85,0 @@ }; |
{ | ||
"name": "oneday-core", | ||
"version": "1.0.55", | ||
"version": "1.0.56", | ||
"description": "Basic AWS util functions to ease development.", | ||
@@ -14,2 +14,3 @@ "main": "index.js", | ||
"chai": "4.2.0", | ||
"moment-timezone": "^0.5.26", | ||
"uuid": "3.3.2" | ||
@@ -16,0 +17,0 @@ }, |
@@ -59,3 +59,3 @@ 'use strict'; | ||
DataType: 'String', | ||
StringValue: new Date().toISOString() | ||
StringValue: util.now() | ||
}, | ||
@@ -94,3 +94,3 @@ 'TopicName': { | ||
responseCode: error.statusCode, | ||
created: new Date().toISOString() | ||
created: util.now() | ||
} | ||
@@ -97,0 +97,0 @@ }; |
10
util.js
@@ -0,1 +1,3 @@ | ||
const moment = require('moment-timezone'); | ||
module.exports.getDynamoDbArn = getDynamoDbArn; | ||
@@ -15,2 +17,3 @@ module.exports.getSnsArn = getSnsArn; | ||
module.exports.aggregateByProperty = aggregateByProperty; | ||
module.exports.now = now; | ||
@@ -183,2 +186,9 @@ function getDynamoDbArn(region, accountid, table) { | ||
return result; | ||
} | ||
/* Returns the current local datetime in ISO8601 format with timezone, but without nanoseconds. | ||
Eg: 2019-09-18T02:01:43+08:00 | ||
*/ | ||
function now(){ | ||
return moment().format(); | ||
} |
34577
898
4
+ Addedmoment-timezone@^0.5.26
+ Addedmoment@2.30.1(transitive)
+ Addedmoment-timezone@0.5.46(transitive)