# LGF_GetCalendarWeek_ISO (FC / 3.0.1)

Overview

Author: Siemens Digital Industry

## Short description

This function uses the specified date to calculate the calendar week and the number of days that have passed since the beginning of the year for ISO 8601 European countries.

### Block Interface

| LGF_GetCalendarWeek_ISO (FC) |
--- | --- | ---
DTL |  |  | date |  | Ret_Val |  |  | DInt
|  |  |  |  | calendarDay |  |  | DInt
|  |  |  |  | error |  |  | Bool
|  |  |  |  | status |  |  | Word

### Input parameter

Identifier | Data type | Description
--- | --- | ---
date | DTL | Date used to calculate the calendar week and days since 1 January

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | DInt | Number of the calendar week.
calendarDay | DInt | Days past since January 1st on given date
error | Bool | FALSE: No error / TRUE: An error occurred during the execution of the FB
status | Word | 16#0000-16#7FFF: Status of the FB / 16#8000-16#FFFF: Error identification (see following Table)

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_NO_ERROR Status: no error occurred
16#8201 | ERR_LIM_DATE Date out of the range, has to be greater than <1970-01-01 ; 2262-04-11>

## Functional description

### Counting method for European countries in accordance with ISO 8601

- Calendar weeks have 7 days, start on a Monday, and they are counted continuously throughout the year
- Calendar week 1 of a year is the week that contains the first Thursday.
- Each year has either 52 or 53 calendar weeks.
- A year has 53 calendar weeks if the following characteristics apply:
  - A common year begins on a Thursday and ends on a Thursday.
  - A leap year begins either on a Wednesday and ends on a Thursday or it begins on a Thursday and ends on a Friday.
- The 29th, 30th and 31st December can belong to the calendar week 1 of the following year.
- The 1st, 2nd, and 3rd January can still belong to the last calendar week of the previous year.

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 27.01.2017 | First released version
| 1.0.1 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.2 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 1.0.3 | Simatic Systems Support
| 16.07.2019 | Renamed from LGF_CalenderWeek to LGF_CalenderWeek_ISO Function split into week for ISO and US Format and as well day counter. Result passed as return value. Standard header implemented Constant, temp variable naming Update function call of CalendarDay
| 3.0.0 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 19.01.2020 | Insert documentation