feature: if the provided date is 'now', create a date (#14)

This commit is contained in:
harttle
2016-10-23 00:11:22 +08:00
parent baac31b037
commit 300c3710c6
5 changed files with 46 additions and 12 deletions
+4 -2
View File
@@ -1,3 +1,5 @@
const _ = require('./util/underscore.js');
var Scope = {
safeGet: function(str) {
var i;
@@ -41,7 +43,7 @@ var Scope = {
};
function setPropertyByPath(obj, path, val) {
if (path instanceof String || typeof path === 'string') {
if (_.isString(path)) {
var paths = path.replace(/\[/g, '.').replace(/\]/g, '').split('.');
for (var i = 0; i < paths.length; i++) {
var key = paths[i];
@@ -58,7 +60,7 @@ function setPropertyByPath(obj, path, val) {
}
function getPropertyByPath(obj, path) {
if (path instanceof String || typeof path === 'string') {
if (_.isString(path)) {
var paths = path.replace(/\[/g, '.').replace(/\]/g, '').split('.');
paths.forEach(p => obj = obj && obj[p]);
return obj;