Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14df9ae2cd | ||
|
|
36f2535cf8 |
3
dist/timehelper.d.ts
vendored
3
dist/timehelper.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
export declare class TimeSpan {
|
||||
private start;
|
||||
private end;
|
||||
constructor(timeSpanStr: string);
|
||||
private timeZone;
|
||||
constructor(timeSpanStr: string, timeZone: string);
|
||||
private parseTime;
|
||||
contains(timestamp?: number): boolean;
|
||||
}
|
||||
|
||||
2
dist/timehelper.d.ts.map
vendored
2
dist/timehelper.d.ts.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CAClD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,WAAW,CAOb;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"}
|
||||
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBlD;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CAClD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,WAAW,CAOb;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"}
|
||||
13
dist/timehelper.js
vendored
13
dist/timehelper.js
vendored
@@ -1,10 +1,12 @@
|
||||
export class TimeSpan {
|
||||
start;
|
||||
end;
|
||||
constructor(timeSpanStr) {
|
||||
timeZone;
|
||||
constructor(timeSpanStr, timeZone) {
|
||||
const [startStr, endStr] = timeSpanStr.split("-");
|
||||
this.start = this.parseTime(startStr);
|
||||
this.end = this.parseTime(endStr);
|
||||
this.timeZone = timeZone;
|
||||
}
|
||||
parseTime(timeStr) {
|
||||
const [hours, minutes] = timeStr.split(":").map(Number);
|
||||
@@ -12,8 +14,13 @@ export class TimeSpan {
|
||||
}
|
||||
contains(timestamp = Date.now()) {
|
||||
const date = new Date(timestamp);
|
||||
const hours = date.getHours();
|
||||
const minutes = date.getMinutes();
|
||||
const berlinTimeStr = date.toLocaleString("de-DE", {
|
||||
timeZone: this.timeZone, // "Europe/Berlin"
|
||||
hour12: false,
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
const [hours, minutes] = berlinTimeStr.split(":").map(Number);
|
||||
const currentMinutes = hours * 60 + minutes;
|
||||
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
||||
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@dpu/shared",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@dpu/shared",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"chalk": "^5.6.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dpu/shared",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
export class TimeSpan {
|
||||
private start: { hours: number; minutes: number };
|
||||
private end: { hours: number; minutes: number };
|
||||
private timeZone;
|
||||
|
||||
constructor(timeSpanStr: string) {
|
||||
constructor(timeSpanStr: string, timeZone: string) {
|
||||
const [startStr, endStr] = timeSpanStr.split("-");
|
||||
this.start = this.parseTime(startStr);
|
||||
this.end = this.parseTime(endStr);
|
||||
this.timeZone = timeZone;
|
||||
}
|
||||
|
||||
private parseTime(timeStr: string) {
|
||||
@@ -16,10 +18,15 @@ export class TimeSpan {
|
||||
contains(timestamp: number = Date.now()): boolean {
|
||||
const date = new Date(timestamp);
|
||||
|
||||
const hours = date.getHours();
|
||||
const minutes = date.getMinutes();
|
||||
const currentMinutes = hours * 60 + minutes;
|
||||
const berlinTimeStr = date.toLocaleString("de-DE", {
|
||||
timeZone: this.timeZone, // "Europe/Berlin"
|
||||
hour12: false,
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
|
||||
const [hours, minutes] = berlinTimeStr.split(":").map(Number);
|
||||
const currentMinutes = hours * 60 + minutes;
|
||||
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
||||
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user