BSL097 — Using of the deprecated method "CurrentDate"¶
Summary¶
Using of the deprecated method "CurrentDate"
Identifiers¶
| Field | Value |
|---|---|
| Rule code | BSL097 |
| Compatible alias | DeprecatedCurrentDate |
| Severity | WARNING |
| Enabled by default | Yes |
| Implemented | Yes |
| Tags | standard, deprecated, unpredictable |
Behavior¶
- The public identifier
BSL097and aliasDeprecatedCurrentDateare stable. - The rule reports the cases documented on this page.
- Suppressions and project configuration are applied before publication.
- The rule requires neither an external analyzer nor network access.
Configuration and suppression¶
BSL### is the primary stable identifier. The compatible alias is accepted
in select, ignore, and compatible block suppression comments.
All three suppression families support both a current line and a range. When an opening comment follows code, it affects only that line. Use any one form:
noqa:
bsl-disable:
- compatible
BSLLSform:
When the same opening comment is on a line by itself, it starts a range. Close it with the matching marker from the same family:
// noqa: BSL097
// code without this diagnostic
// noqa-enable: BSL097
// bsl-disable: BSL097
// code without this diagnostic
// bsl-enable: BSL097
// BSLLS:DeprecatedCurrentDate-off
// code without this diagnostic
// BSLLS:DeprecatedCurrentDate-on
To disable the rule until the end of the file, omit the closing
noqa-enable, bsl-enable, or BSLLS:…-on marker.
Opening and closing markers must belong to the same family.
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:
Right:
On server¶
Right: