FTODate

The FTODate class provides comprehensive date and time manipulation functionality, with support for different time zones and time units.

Methods

Method
Description
Return Value

valueOf(timeUnit = TimeUnit.MILLISECONDS)

Gets the timestamp value in specified time unit

number - Timestamp in specified unit

toMilliseconds(timeZoneMode = TimeZoneMode.PROJECT)

Converts the date to milliseconds in specified timezone

number - Milliseconds since epoch

toSeconds(timeZoneMode = TimeZoneMode.PROJECT)

Converts the date to seconds in specified timezone

number - Seconds since epoch

toString(timeZoneMode = TimeZoneMode.PROJECT)

Converts the date to ISO string in specified timezone

string - ISO formatted date string

toJSDate(timeZoneMode = TimeZoneMode.PROJECT)

Converts to JavaScript Date object in specified timezone

Date - JavaScript Date object

dayOfMonth(timeZoneMode = TimeZoneMode.PROJECT)

Gets the day of month (1-31)

number - Day of month

monthOf(timeZoneMode = TimeZoneMode.PROJECT)

Gets the month (1-12)

number - Month number

weekOf(timeZoneMode = TimeZoneMode.PROJECT)

Gets the week number of the year

number - Week number

yearOf(timeZoneMode = TimeZoneMode.PROJECT)

Gets the year

number - Full year

dayOfYear(timeZoneMode = TimeZoneMode.PROJECT)

Gets the day of year (1-366)

number - Day of year

dayOfWeek(timeZoneMode = TimeZoneMode.PROJECT)

Gets the day of week (0-6, 0=Sunday)

number - Day of week

hour(timeZoneMode = TimeZoneMode.PROJECT)

Gets the hour (0-23)

number - Hour

minute(timeZoneMode = TimeZoneMode.PROJECT)

Gets the minute (0-59)

number - Minute

second(timeZoneMode = TimeZoneMode.PROJECT)

Gets the second (0-59)

number - Second

Example Usage

// Create FTODate instance
const date = this.api.createFTODate(1707739200); // 2024.02.12 12:00:00 UTC

// Get components in project timezone
console.log(`Year: ${date.yearOf()}`);
console.log(`Month: ${date.monthOf()}`);
console.log(`Day: ${date.dayOfMonth()}`);
console.log(`Hour: ${date.hour()}`);
console.log(`Minute: ${date.minute()}`);
console.log(`Second: ${date.second()}`);

// Get components in UTC
console.log(`UTC Year: ${date.yearOf(TimeZoneMode.UTC)}`);
console.log(`UTC Month: ${date.monthOf(TimeZoneMode.UTC)}`);

// Convert to different formats
console.log(`Milliseconds: ${date.toMilliseconds()}`);
console.log(`Seconds: ${date.toSeconds()}`);
console.log(`ISO String: ${date.toString()}`);
console.log(`JS Date: ${date.toJSDate()}`);

// Get calendar information
console.log(`Day of Week: ${date.dayOfWeek()}`); // 0=Sunday
console.log(`Day of Year: ${date.dayOfYear()}`);
console.log(`Week of Year: ${date.weekOf()}`);

Last updated