@laboratory-one/api-components 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laboratory-one/api-components",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "API components for Laboratory One",
5
5
  "author": "Laboratory One",
6
6
  "private": false,
@@ -23,6 +23,7 @@ import {
23
23
  cleanString,
24
24
  cleanStringAndLowercase,
25
25
  handleError,
26
+ utcOffsetToHours,
26
27
  } from '../utils';
27
28
  import { AuthGuard } from '../guard';
28
29
 
@@ -151,7 +152,7 @@ export class UserController {
151
152
  ? cleanStringAndLowercase(dto.fullName)
152
153
  : undefined,
153
154
  pushToken: dto.pushToken ? cleanString(dto.pushToken) : undefined,
154
- tz: dto.tz ? dto.tz : undefined,
155
+ tz: dto.tz ? utcOffsetToHours(dto.tz) : undefined,
155
156
  };
156
157
 
157
158
  const user: User = await this.userService.update(
@@ -20,3 +20,13 @@ export const cleanPhoneNumber = (str: string): string => {
20
20
 
21
21
  return `+1${trimmed}`;
22
22
  };
23
+
24
+ export const utcOffsetToHours = (utcOffset: number): number => {
25
+ const hours = Math.floor(utcOffset / 60);
26
+
27
+ if (hours > 0) {
28
+ return 24 - hours;
29
+ }
30
+
31
+ return Math.abs(hours);
32
+ };