Skip to content

Commit

Permalink
feat: Add parseString method to supply missing date string parsing in…
Browse files Browse the repository at this point in the history
… date-fns, if the time zone is not given from outside

* Fix the UTC offset addition in parseFromTimeZone.
* Upgrade timezone-support to gain conversion methods between date and time objects.
* Test and debug the ES6 sources directly without a debug compilation to CJS.
  • Loading branch information
prantlf committed Sep 19, 2018
1 parent d98d829 commit 9fc80de
Show file tree
Hide file tree
Showing 17 changed files with 14,463 additions and 66 deletions.
1 change: 1 addition & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": [
"src/convertToLocalTime.js",
"src/convertToTimeZone.js",
"src/parseFromString.js",
"src/parseFromTimeZone.js",
"src/formatToTimeZone.js"
]
Expand Down
4 changes: 1 addition & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"name": "Test",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"-i",
"--testPathIgnorePatterns",
"browser.test.js"
"-i"
],
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": [
Expand Down
8 changes: 1 addition & 7 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
"isDefault": true
}
},
{
"label": "build:debug",
"type": "npm",
"script": "build:debug",
"problemMatcher": []
},
{
"label": "test",
"type": "npm",
Expand All @@ -30,4 +24,4 @@
}
},
]
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ utm_content=prantlf/date-fns-timezone&utm_campaign=Badge_Grade)
[![devDependency Status](https://david-dm.org/prantlf/date-fns-timezone/dev-status.svg)](https://david-dm.org/prantlf/date-fns-timezone#info=devDependencies)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Provides parsing and formatting date strings and time zone conversions supporting [IANA time zones]. Date parsing, formatting and other queries and manipulations are provided by [date-fns]. List of canonical time zone names and time zone conversions are provided by [timezone-support].
Provides parsing and formatting date strings and time zone conversions supporting [IANA time zones], following the design of functions in [date-fns]. List of canonical time zone names is provided by [timezone-support].

- [Synopsis](#synopsis)
- [Installation and Loading](#installation-and-loading)
Expand Down Expand Up @@ -143,6 +143,12 @@ const enteredTime = '2018-09-02 12:04:30.982'
const timeZone = 'Europe/Berlin'
const storedDate = parseFromTimeZone(enteredTime, { timeZone })
// Contains date "2018-09-02T10:04:30.982Z"

const enteredTime = '09/02/2018 12:04:30.982 PM'
const customFormat = 'MM/DD/YYYY h:mm:ss.SSS A'
const timeZone = 'America/New_York'
const storedDate = parseFromTimeZone(enteredTime, { timeZone })
// Contains date "2018-09-02T18:04:30.982Z"
```

See the function [parseFromTimeZone](#parsefromtimezone) for more information.
Expand Down

0 comments on commit 9fc80de

Please sign in to comment.