Skip to content

Commit

Permalink
Merge pull request #87 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain committed Jan 9, 2019
2 parents 6ded8d6 + 17b37fd commit 472542b
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 59 deletions.
2 changes: 1 addition & 1 deletion _version.js
@@ -1 +1 @@
module.exports='5.2.0'
module.exports='5.2.1'
19 changes: 14 additions & 5 deletions builds/spacetime.js
@@ -1,12 +1,12 @@
/* spacetime v5.2.0
/* spacetime v5.2.1
github.com/spencermountain/spacetime
MIT
*/

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.spacetime = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
"use strict";

module.exports = '5.2.0';
module.exports = '5.2.1';

},{}],2:[function(_dereq_,module,exports){
'use strict';
Expand Down Expand Up @@ -1043,13 +1043,22 @@ var addMethods = function addMethods(SpaceTime) {
want.month = old.month() + num; //month is the one unit we 'model' directly

want = rollMonth(want, old);
} //support coercing a week, too


if (unit === 'week') {
var sum = old.date() + num * 7;

if (sum <= 28 && sum > 1) {
want.date = sum;
}
} //support 25-hour day-changes on dst-changes
else if (unit === 'date') {
//specify a naive date number, if it's easy to do...
var sum = old.date() + num;
var _sum = old.date() + num;

if (sum <= 28 && sum > 1) {
want.date = sum;
if (_sum <= 28 && _sum > 1) {
want.date = _sum;
} //or if we haven't moved at all..
else if (num !== 0 && old.isSame(s, 'day')) {
want.date = old.date() + num;
Expand Down
4 changes: 2 additions & 2 deletions builds/spacetime.min.js

Large diffs are not rendered by default.

182 changes: 138 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "spacetime",
"version": "5.2.0",
"version": "5.2.1",
"description": "figure-out dates across timezones",
"main": "builds/spacetime.js",
"unpkg": "builds/spacetime.min.js",
Expand All @@ -26,7 +26,7 @@
"dependencies": {},
"devDependencies": {
"@babel/core": "7.2.2",
"@babel/preset-env": "7.2.0",
"@babel/preset-env": "7.2.3",
"amble": "0.0.7",
"babelify": "10.0.0",
"browserify": "16.2.3",
Expand All @@ -37,7 +37,7 @@
"tap-dancer": "0.1.2",
"tap-spec": "5.0.0",
"tape": "4.9.1",
"terser": "3.13.1",
"terser": "3.14.1",
"timekeeper": "2.1.2"
}
}
8 changes: 4 additions & 4 deletions scratch.js
Expand Up @@ -2,8 +2,8 @@ const spacetime = require('./src/index')

// let d = spacetime('June 8th').next('month')
// d.log()
let d = spacetime('2019-11-04T00:00:00.000')

let s = spacetime('January 1, 2019 1:20:05')
s = s.time('4:20pm')
s = s.add(1, 'decade')
console.log(s.format('nice-date'))

d = d.add(1, 'week')
console.log(d.format('day-nice'))
7 changes: 7 additions & 0 deletions src/methods/add.js
Expand Up @@ -84,6 +84,13 @@ const addMethods = SpaceTime => {
//month is the one unit we 'model' directly
want = rollMonth(want, old);
}
//support coercing a week, too
if (unit === 'week') {
let sum = old.date() + (num * 7)
if (sum <= 28 && sum > 1) {
want.date = sum
}
}
//support 25-hour day-changes on dst-changes
else if (unit === 'date') {
//specify a naive date number, if it's easy to do...
Expand Down

0 comments on commit 472542b

Please sign in to comment.