GetWeekByDateTime

Returns the week number from an FTODate object.

Syntax

GetWeekByDateTime(ftoDate: FTODate): number

Parameters

  • ftoDate: FTODate - The FTODate object to extract the day from

Return Value

Returns a number representing the week number of the year (1-53).

Description

The GetWeekByDateTime method extracts the week number from an FTODate object. The returned value is between 1 and 53, representing the week of the year.

Example

// Create FTODate object
const currentDate = this.api.TimeCurrent();
const week = this.api.GetWeekByDateTime(currentDate);
console.log(`Week number: ${week}`);

// Calculate weeks remaining in year
const totalWeeks = 52;
const weeksRemaining = totalWeeks - week;
console.log(`Weeks remaining: ${weeksRemaining}`);

// Check if it's first or last week
const isFirstWeek = week === 1;
const isLastWeek = week >= 52;
console.log(`First week: ${isFirstWeek}`);
console.log(`Last week: ${isLastWeek}`);

// Format date with week
const year = currentDate.yearOf();
console.log(`Week ${week} of ${year}`);

Last updated