TimeDaylightSavings

Returns the current daylight savings time (DST) offset in seconds.

Syntax

TimeDaylightSavings(): number

Return Value

Returns a number representing the DST offset in seconds (typically 0 when DST is not in effect, or 3600 (1 hour) during DST).

Description

The TimeDaylightSavings method returns the current daylight savings time offset in seconds.

Example

// Get DST offset
const dstOffset = this.api.TimeDaylightSavings();
console.log(`DST offset: ${dstOffset} seconds`);

// Check if DST is in effect
const isDST = dstOffset > 0;
console.log(`DST is in effect: ${isDST}`);

// Get current time with DST adjustment
const currentTime = this.api.TimeCurrent();
const localTimeWithDST = this.api.createFTODate(
  currentTime.getTime() + dstOffset * 1000
);
console.log(`Local time with DST: ${localTimeWithDST.toString()}`);

// Calculate total timezone offset including DST
const gmtOffset = this.api.TimeGMTOffset();
const totalOffset = gmtOffset + dstOffset;
console.log(`Total timezone offset: ${totalOffset} seconds`);

Last updated