Skip to content

Commit

Permalink
Merge branch 'hfix/1.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
md-akhi committed May 4, 2022
2 parents 70b661d + caca377 commit 3c92d3e
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 61 deletions.
42 changes: 39 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
## 1.2.1 (2022-05-02)
## 1.2.4 (2022-05-04)


### Bug Fixes

* compile ts ([8c28c08](https://github.com/md-akhi/SHDateTime-js/commits/8c28c08f7b89c5d284fc1ec9310504bfad3e0c2c))
* added @babel/core for run auto test ([5d22416](https://github.com/md-akhi/SHDateTime-js/commits/5d2241619f6d2943eec22bbd72ef9dbd83a4eca6))
* fixed set day in setDate, setUTCDate ([f3c9d21](https://github.com/md-akhi/SHDateTime-js/commits/f3c9d21c946b5d19a01a18959ea01a48de7cff7e))


### Features

* **l10n:** added Central Kurdish (Iran) ([3a4c87f](https://github.com/md-akhi/SHDateTime-js/commits/3a4c87f50da726517baa7b51605e488edc6d645b))



Expand Down Expand Up @@ -36,6 +42,10 @@ All notable changes to this project will be documented in this file.

-

### [رفع / درست شد][#]

-

</div>

## [Unreleased]
Expand All @@ -48,6 +58,29 @@ All notable changes to this project will be documented in this file.

-

### [Fixed][#]

-

#

<div style="text-align: center;">

## [1.2.4] - SH 1401-02-14 - G 2022-05-04

</div>
<div dir="rtl" style="text-align: right;">

### [رفع / درست شد][#]

- رفع خطای محاسباتی تاریخ setDate, setUTCDate

</div>

### [Fixed][#]

- Fixed set day in setDate, setUTCDate

#

<div style="text-align: center;">
Expand Down Expand Up @@ -84,6 +117,7 @@ All notable changes to this project will be documented in this file.
<div style="text-align: center;">

#

## [1.1.0] - SH 1400-02-09 - G 2022-04-29

</div>
Expand All @@ -102,6 +136,7 @@ All notable changes to this project will be documented in this file.
<div style="text-align: center;">

#

## [1.0.0] - SH 1400-12-11 - G 2022-03-02

</div>
Expand All @@ -115,7 +150,8 @@ All notable changes to this project will be documented in this file.

#

[unreleased]: https://github.com/md-akhi/SHDateTime-js/compare/1.2.0...HEAD
[unreleased]: https://github.com/md-akhi/SHDateTime-js/compare/1.2.4...HEAD
[1.2.4]: https://github.com/md-akhi/SHDateTime-js/compare/1.2.0...1.2.4
[1.2.0]: https://github.com/md-akhi/SHDateTime-js/compare/1.1.1...1.2.0
[1.1.0]: https://github.com/md-akhi/SHDateTime-js/compare/1.0.0-rc1...1.1.0
[1.0.0]: https://github.com/md-akhi/SHDateTime-js/releases/tag/1.0.0-rc1
Expand Down
55 changes: 26 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@md-akhi/shdatetime",
"version": "1.2.1",
"version": "1.2.4",
"description": "Date and Time Related Extensions SH{Shamsi Hijri, Solar Hijri, Iranian Hijri}",
"keywords": [
"date",
Expand Down Expand Up @@ -43,20 +43,33 @@
"import": "./dist/mjs/index.js",
"types": "./dist/types/index.d.ts"
},
"./words?": {
"require": "./dist/cjs/word.js",
"import": "./dist/mjs/word.js",
"types": "./dist/types/word.d.ts"
},
"./tools?": {
"require": "./dist/cjs/tools.js",
"import": "./dist/mjs/tools.js",
"types": "./dist/types/tools.d.ts"
},
"./l10n/*": {
"require": "./dist/cjs/l10n/*.js",
"import": "./dist/mjs/l10n/*.js",
"types": "./dist/types/l10n/*.d.ts"
},
"./*": {
"require": "./dist/cjs/i18n/*.js",
"import": "./dist/mjs/i18n/*.js",
"types": "./dist/types/i18n/*.d.js"
"types": "./dist/types/i18n/*.d.ts"
}
},
"typesVersions": {
"*": {
".": [
"dist/types/index.d.ts"
],
"./*": [
"./dist/types/i18n/*.d.js"
]
".": ["dist/types/index.d.ts"],
"./words?": ["./dist/types/word.d.ts"],
"./tools?": ["./dist/types/tools.d.ts"],
"./*": ["./dist/types/i18n/*.d.ts"]
}
},
"directories": {
Expand All @@ -65,16 +78,8 @@
"tests": "./tests",
"docs": "./docs"
},
"files": [
"LICENSE",
"README.md",
"CHANGELOG.md",
"docs",
"dist"
],
"man": [
"./docs/**/*.md"
],
"files": ["LICENSE", "README.md", "CHANGELOG.md", "docs", "dist"],
"man": ["./docs/**/*.md"],
"repository": {
"type": "git",
"url": "https://github.com/md-akhi/SHDateTime-js.git"
Expand All @@ -84,6 +89,7 @@
},
"homepage": "https://github.com/md-akhi/SHDateTime-js#readme",
"devDependencies": {
"@babel/core": "^7.17.10",
"@babel/preset-env": "^7.16.11",
"@tsconfig/recommended": "^1.0.1",
"@types/chai": "^4.3.0",
Expand All @@ -98,12 +104,10 @@
"eslint-config-recommended": "^4.1.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-clean": "^0.4.0",
"gulp-concat": "^2.6.1",
"gulp-header": "^2.0.9",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.3",
"gulp-sourcemaps": "^3.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"gulp-uglify": "^3.0.2",
"husky": "^7.0.4",
Expand All @@ -121,14 +125,7 @@
}
},
"lint-staged": {
"/**/*.{ts}": [
"prettier --write",
"eslint --fix",
"git add"
],
"*": [
"prettier --write",
"git add"
]
"/**/*.{ts}": ["prettier --write", "eslint --fix", "git add"],
"*": ["prettier --write", "git add"]
}
}
61 changes: 35 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @link http://codehub.akhi.ir/js/SHDateTime
* @copyright Copyright (C) 2015 - 2022 Open Source Matters,Inc. All right reserved.
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL-3.0 License
* @version Release: 1.2.1
* @version Release: 1.2.4
*/

import Word from "./word.js";
Expand All @@ -28,7 +28,7 @@ export default class SHDate {
/**
* version of SHDate
*/
static version: string = "1.2.1";
static version: string = "1.2.4";
/**
* @type {number[]} days in month without leap year
*/
Expand Down Expand Up @@ -169,29 +169,38 @@ export default class SHDate {

/**
* update date
* @param {boolean} isUTC
* @returns {null}
* @since 1.0.0
*/
#update(): void {
#updateDate(): void {
const [UTC_year, UTC_month, UTC_date] = this.#GregorianToSolar(
this.#date.getUTCFullYear(),
this.#date.getUTCMonth(),
this.#date.getUTCDate()
);
this.#sh.UTC_year = UTC_year;
this.#sh.UTC_month = UTC_month;
this.#sh.UTC_date = UTC_date;

const [year, month, date] = this.#GregorianToSolar(
this.#date.getFullYear(),
this.#date.getMonth(),
this.#date.getDate()
);
this.#sh.UTC_year = UTC_year;
this.#sh.UTC_month = UTC_month;
this.#sh.UTC_date = UTC_date;
this.#sh.year = year;
this.#sh.month = month;
this.#sh.date = date;
return;
}
/**
* update time
* @returns {null}
* @since 1.2.2
*/
#updateTime(): void {
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
return;
}
/**
* Convert gregorian date to solar hijri date
* @param {number} gyear - gregorian year
Expand Down Expand Up @@ -713,7 +722,7 @@ export default class SHDate {
): number {
const [gyear, gmonth, gdate] = this.#SolarToGregorian(year, month, date);
this.#date.setFullYear(gyear, gmonth, gdate);
this.#update();
this.#updateDate();
return this.getTime();
}

Expand All @@ -732,7 +741,7 @@ export default class SHDate {
): number {
const [gyear, gmonth, gdate] = this.#SolarToGregorian(year, month, date);
this.#date.setUTCFullYear(gyear, gmonth, gdate);
this.#update();
this.#updateDate();
return this.getTime();
}

Expand All @@ -749,8 +758,8 @@ export default class SHDate {
month,
date
);
this.#date.setMonth(gmonth, gdate);
this.#update();
this.#date.setFullYear(gyear, gmonth, gdate);
this.#updateDate();
return this.getTime();
}

Expand All @@ -767,8 +776,8 @@ export default class SHDate {
month,
date
);
this.#date.setUTCMonth(gmonth, gdate);
this.#update();
this.#date.setUTCFullYear(gyear, gmonth, gdate);
this.#updateDate();
return this.getTime();
}

Expand All @@ -784,8 +793,8 @@ export default class SHDate {
this.getMonth(),
date
);
this.#date.setDate(gdate);
this.#update();
this.#date.setFullYear(gyear, gmonth, gdate);
this.#updateDate();
return this.getTime();
}

Expand All @@ -801,8 +810,8 @@ export default class SHDate {
this.getUTCMonth(),
date
);
this.#date.setUTCDate(gdate);
this.#update();
this.#date.setUTCFullYear(gyear, gmonth, gdate);
this.#updateDate();
return this.getTime();
}

Expand All @@ -823,7 +832,7 @@ export default class SHDate {
milliseconds: number = this.getMilliseconds()
): number {
this.#date.setHours(hours, minutes, seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -844,7 +853,7 @@ export default class SHDate {
milliseconds: number = this.getUTCMilliseconds()
): number {
this.#date.setUTCHours(hours, minutes, seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -863,7 +872,7 @@ export default class SHDate {
milliseconds: number = this.getMilliseconds()
): number {
this.#date.setMinutes(minutes, seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -882,7 +891,7 @@ export default class SHDate {
milliseconds: number = this.getUTCMilliseconds()
): number {
this.#date.setUTCMinutes(minutes, seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -899,7 +908,7 @@ export default class SHDate {
milliseconds: number = this.getMilliseconds()
): number {
this.#date.setSeconds(seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -915,7 +924,7 @@ export default class SHDate {
milliseconds: number = this.getUTCMilliseconds()
): number {
this.#date.setUTCSeconds(seconds, milliseconds);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -927,7 +936,7 @@ export default class SHDate {
*/
public setMilliseconds(ms: number): number {
this.#date.setMilliseconds(ms);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand All @@ -939,7 +948,7 @@ export default class SHDate {
*/
public setUTCMilliseconds(ms: number): number {
this.#date.setUTCMilliseconds(ms);
this.#date.setTime(this.#date.getTime() + this.#config.time_server_diff);
this.#updateTime();
return this.getTime();
}

Expand Down Expand Up @@ -1110,7 +1119,7 @@ export default class SHDate {
public setTime(time: number): number {
//if (isUTC) return this.#date.setUTCTime(time);
this.#date.setTime(time + this.#config.time_server_diff);
this.#update();
this.#updateDate();
return this.getTime();
}

Expand Down
Loading

0 comments on commit 3c92d3e

Please sign in to comment.