Skip to content

Commit

Permalink
update(module/date): update main.ts
Browse files Browse the repository at this point in the history
Signed-off-by: dy-xiaodong2022 <[email protected]>
  • Loading branch information
xiaodong2008 committed Dec 22, 2023
1 parent 6f3e10d commit 5d22eaa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/date/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {extractIgnoreTokens, getReplacement} from "./lib";
import {fDate} from "./def";

class FastjsDate extends FastjsBaseModule<FastjsDate> {
public readonly construct: string = "FastjsDate";
public _date: number;
public _createAt: number = Date.now();
public readonly construct: string = "FastjsDate"

public timezoneDiff: number = new Date().getTimezoneOffset() * 60 * 1000;

constructor(format: string, date: fDate)
Expand Down Expand Up @@ -38,7 +37,7 @@ class FastjsDate extends FastjsBaseModule<FastjsDate> {
changeDate(date: string, format?: string): FastjsDate;
changeDate(date: number | Date | string, format: string = this.format): FastjsDate {
if (typeof date === "string") {
date = this.parseFormatString(this.format, date);
date = this.parseFormatString(format, date);
} else if (date instanceof Date) {
date = date.getTime();
}
Expand Down Expand Up @@ -69,7 +68,7 @@ class FastjsDate extends FastjsBaseModule<FastjsDate> {
const [formatString, ignoreTokens] = extractIgnoreTokens(newFormat || this.format);

let result = formatString;
for (const replace of this.getReplacement(date)) {
for (const replace of getReplacement(date)) {
const format = replace[0];
const replacement = replace[1];
result = result.replace(new RegExp(format, "g"), String(replacement));
Expand Down

0 comments on commit 5d22eaa

Please sign in to comment.