Skip to content

Using of the deprecated method "CurrentDate" (DeprecatedCurrentDate)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Error BSL Major Yes 5 standard
deprecated
unpredictable

Description

The configurations must be designed to work in conditions where the time zone on the server computer does not match the real time zone of the infobase users. For example, employees of a company from Vladivostok work with a server located in Moscow, and all operations in the system must be performed in local time (Vladivostok).

Such a work scenario is often in demand in client-server infobases and in applied solutions in the service model (SaaS).

In all server procedures and functions, instead of the CurrentDate function, which returns the server computer's date and time, you should use the CurrentSessionDate function, which converts the server's time to the user's session time zone.

In client code, using the CurrentDate function is also not allowed. This requirement is due to the fact that the current time calculated in the client and server code must not differ.

When using the Library of Standard Subsystems, it is recommended to use the DateSession function of the general module GeneralPurposeClient.

Examples

On the client

Wrong:

OperationDate = CurrentDate();

Right:

OperationDate = GeneralPurposeClient.SessionDate();

On server

OperationDate = CurrentDate();

Right:

OperationDate = CurrentSessionDate();

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:DeprecatedCurrentDate-off
// BSLLS:DeprecatedCurrentDate-on

Parameter for config

"DeprecatedCurrentDate": false