teableio/teable

View on GitHub
apps/nestjs-backend/src/db-provider/search-query/get-offset.ts

Summary

Maintainability
A
0 mins
Test Coverage
import dayjs from 'dayjs';
import 'dayjs/plugin/utc';

export function getOffset(timeZone: string) {
  const offsetMinutes = dayjs().tz(timeZone).utcOffset();

  const offsetHours = offsetMinutes / 60;
  return offsetHours >= 0 ? `+${offsetHours}` : `${offsetHours}`;
}