From f7c0e6e22af7ac2f31ae4fc4e87cd27f6df67cc3 Mon Sep 17 00:00:00 2001 From: Sam Shepherd Date: Mon, 13 Feb 2017 13:15:26 -0600 Subject: [PATCH 1/2] Fixed an odd issue where regex was not working correctly causing dates to not be parsed correctly. --- lib/index.js | 2 +- spec/specs.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 6f67e79..66000db 100644 --- a/lib/index.js +++ b/lib/index.js @@ -547,7 +547,7 @@ Utils.parseDateTimeField = function(field, options) { if (SugarDate.isValid(parsedDateWithTimezone)) { Utils.Logger.debug('Utils.parseDateTimeField: parsedDateWithTimezone:', parsedDateWithTimezone.toISOString()); - var hasTZOffset = new RegExp('[zZ]|[+-][01]\d:?[0-5]\d').test(field); + var hasTZOffset = /[zZ]|[+-][01]\d:?[0-5]\d/.test(field); // Convert to string. Important to remove offset/tz info (if none was provided originally) // or moment will ignore the passed in tz in later step. diff --git a/spec/specs.js b/spec/specs.js index d84455e..bd16fec 100644 --- a/spec/specs.js +++ b/spec/specs.js @@ -1160,6 +1160,11 @@ describe('Utils', function() { var expected = moment('1995-12-26T01:30:00+04:30').toDate(); expectValidDate('1995-12-25T13:30:00+0430 +1d - 12h', expected); }); + + it('should work with timezone', function() { + var date = Utils.parseDateTimeField('2016-7-22T00:00:00+01:00', {timezone: 'Europe/London'}); + expect(date.moment.toISOString()).toEqual('2016-07-21T23:00:00.000Z'); + }); }); }); }); From 1633544926f9e88a7ba6aacf4da57a6675e90d9f Mon Sep 17 00:00:00 2001 From: Sam Shepherd Date: Mon, 13 Feb 2017 13:19:40 -0600 Subject: [PATCH 2/2] v3.0.2 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9499d0c..64bc1d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.0.2] - 2017-02-13 + +### Fixes +- Fixed an odd issue where regex was not working correctly causing dates to not be parsed correctly. + ## [3.0.1] - 2017-02-13 ### Fixes @@ -151,6 +156,7 @@ backoff.attemptAsync(operation, options).then(res => { ### Added - Initial release. +[3.0.2]: https://github.com/flowxo/flowxo-utils/compare/v3.0.1...v3.0.2 [3.0.1]: https://github.com/flowxo/flowxo-utils/compare/v3.0.0...v3.0.1 [3.0.0]: https://github.com/flowxo/flowxo-utils/compare/v2.1.0...v3.0.0 [2.1.0]: https://github.com/flowxo/flowxo-utils/compare/v2.0.0...v2.1.0 diff --git a/package.json b/package.json index ca2d2ec..0af90e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flowxo-utils", - "version": "3.0.1", + "version": "3.0.2", "description": "Common utilities for Flow XO.", "main": "lib/index.js", "scripts": {