Skip to content

Commit de7c9f4

Browse files
committed
fix granularity origin formatting in local timezone
1 parent 1537c9f commit de7c9f4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/cubejs-schema-compiler/src/adapter/Granularity.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class Granularity {
1313

1414
public readonly granularityInterval: string;
1515

16+
public readonly queryTimezone: string;
17+
1618
public readonly granularityOffset: string | undefined;
1719

1820
public readonly origin: moment.Moment;
@@ -25,6 +27,7 @@ export class Granularity {
2527
) {
2628
this.granularity = timeDimension.granularity;
2729
this.predefinedGranularity = isPredefinedGranularity(this.granularity);
30+
this.queryTimezone = query.timezone;
2831
this.origin = moment.tz(query.timezone).startOf('year'); // Defaults to current year start
2932

3033
if (this.predefinedGranularity) {
@@ -59,7 +62,7 @@ export class Granularity {
5962
* @returns origin date string in Query timezone
6063
*/
6164
public originLocalFormatted(): string {
62-
return this.origin.format('YYYY-MM-DDTHH:mm:ss.SSS');
65+
return this.origin.tz(this.queryTimezone).format('YYYY-MM-DDTHH:mm:ss.SSS');
6366
}
6467

6568
/**

0 commit comments

Comments
 (0)