29 lines
802 B
TypeScript
29 lines
802 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {getTimeZone} from 'react-native-localize';
|
|
|
|
import type UserModel from '@typings/database/models/servers/user';
|
|
|
|
export const isTimezoneEnabled = (config: Partial<ClientConfig>) => {
|
|
return config?.ExperimentalTimezone === 'true';
|
|
};
|
|
|
|
export function getDeviceTimezone() {
|
|
return getTimeZone();
|
|
}
|
|
|
|
export const getUserTimezone = (currentUser: UserModel) => {
|
|
if (currentUser?.timezone) {
|
|
return {
|
|
...currentUser?.timezone,
|
|
useAutomaticTimezone: currentUser?.timezone?.useAutomaticTimezone === 'true',
|
|
};
|
|
}
|
|
|
|
return {
|
|
useAutomaticTimezone: true,
|
|
automaticTimezone: '',
|
|
manualTimezone: '',
|
|
};
|
|
};
|