Skip to content

Commit

Permalink
fix(dateTime)!: correctly works with timezones, utc offsets and DST (#41
Browse files Browse the repository at this point in the history
)

- rewritten internal date-maths
- corrected DateTime's public API types

Breaking changes:
- work with UTC the same as with other timezones, in case if input date does not contain timezone information

```js
guessUserTimeZone() == 'Europe/Moscow';
 // Before
dateTime({input: '2023-12-31', timeZone: 'UTC') == '2023-12-31T00:00Z'
// After
dateTime({input: '2023-12-31', timeZone: 'UTC') == '2023-12-30T21:00Z'
```
  • Loading branch information
ValeraS authored Dec 28, 2023
1 parent 8ea079c commit 23488cc
Show file tree
Hide file tree
Showing 40 changed files with 10,830 additions and 7,064 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": ["@gravity-ui/eslint-config", "@gravity-ui/eslint-config/prettier"],
"extends": [
"@gravity-ui/eslint-config",
"@gravity-ui/eslint-config/import-order",
"@gravity-ui/eslint-config/prettier"
],
"root": true,
"env": {
"node": true,
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ name: CI

on:
push:
branches: [main]
branches: [main, next]
pull_request:
branches: [main]

jobs:
verify_files:
name: Verify Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 18
cache: 'npm'
- name: Install Packages
run: npm ci
Expand All @@ -32,13 +31,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 18
cache: 'npm'
- name: Install Packages
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 14
node-version: 18
4 changes: 2 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint -e
6 changes: 3 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

./node_modules/.bin/nano-staged
npx nano-staged
1 change: 1 addition & 0 deletions .nvm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build
build
package-lock.json
CHANGELOG.md
CONTRIBUTING.md
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.ts$': ['ts-jest', {tsconfig: {verbatimModuleSyntax: false}}],
},
setupFilesAfterEnv: ['<rootDir>/setup-tests.ts'],
};
Loading

0 comments on commit 23488cc

Please sign in to comment.