Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/main/date/src/timezone/ |
Upload File : |
import { Cache, Loc, Text } from 'main.core'; const cache = new Cache.MemoryCache(); export type OffsetInterface = { SERVER_TO_UTC: number, USER_TO_SERVER: number, BROWSER_TO_UTC: number, } /** * @memberOf BX.Main.Timezone * * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. * It is not designed to handle this case and will definitely break. */ const Offset: OffsetInterface = { get SERVER_TO_UTC(): number { return cache.remember('SERVER_TO_UTC', () => { return Text.toInteger(Loc.getMessage('SERVER_TZ_OFFSET')); }); }, get USER_TO_SERVER(): number { return cache.remember('USER_TO_SERVER', () => { return Text.toInteger(Loc.getMessage('USER_TZ_OFFSET')); }); }, // Date returns timezone offset in minutes by default, change it to seconds // Also offset is negative in UTC+ timezones and positive in UTC- timezones. // By convention Bitrix uses the opposite approach, so change offset sign. get BROWSER_TO_UTC(): number { return cache.remember('BROWSER_TO_UTC', () => { const offset = Text.toInteger((new Date()).getTimezoneOffset() * 60); return -offset; }); }, }; Object.freeze(Offset); export { Offset, };