Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ dist/*

# Vercel
.vercel

/docker
3 changes: 2 additions & 1 deletion dist/index.css

Large diffs are not rendered by default.

56,214 changes: 56,075 additions & 139 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/database/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const intervals = require('../constants/intervals')
const createArray = require('../utils/createArray')
const matchesDate = require('../utils/matchesDate')
const recursiveId = require('../utils/recursiveId')
const convertTimezoneToOffset = require('../utils/convertTimezoneToOffset')

const response = (entry) => ({
id: entry.id,
Expand Down Expand Up @@ -70,7 +71,7 @@ const getChart = async (ids, type, interval, limit, dateDetails) => {
// Database entries include the day, month and year in the
// timezone of the user. We therefore need to match it against a
// date in the timezone of the user.
const userZonedDate = utcToZonedTime(date, dateDetails.userTimeZone)
const userZonedDate = utcToZonedTime(date, convertTimezoneToOffset(dateDetails.userTimeZone))

// Find a entry that matches the date
const entry = entries.find((entry) => {
Expand Down
3 changes: 2 additions & 1 deletion src/database/durations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const intervals = require('../constants/intervals')
const createArray = require('../utils/createArray')
const matchesDate = require('../utils/matchesDate')
const recursiveId = require('../utils/recursiveId')
const convertTimezoneToOffset = require('../utils/convertTimezoneToOffset')

const get = async (ids, interval, limit, dateDetails) => {
const aggregation = (() => {
Expand All @@ -25,7 +26,7 @@ const get = async (ids, interval, limit, dateDetails) => {
// Database entries include the day, month and year in the
// timezone of the user. We therefore need to match it against a
// date in the timezone of the user.
const userZonedDate = utcToZonedTime(date, dateDetails.userTimeZone)
const userZonedDate = utcToZonedTime(date, convertTimezoneToOffset(dateDetails.userTimeZone))

// Find a entry that matches the date
const entry = entries.find((entry) => {
Expand Down
3 changes: 2 additions & 1 deletion src/database/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const intervals = require('../constants/intervals')
const createArray = require('../utils/createArray')
const matchesDate = require('../utils/matchesDate')
const recursiveId = require('../utils/recursiveId')
const convertTimezoneToOffset = require('../utils/convertTimezoneToOffset')

const get = async (ids, type, interval, limit, dateDetails) => {
const aggregation = (() => {
Expand All @@ -27,7 +28,7 @@ const get = async (ids, type, interval, limit, dateDetails) => {
// Database entries include the day, month and year in the
// timezone of the user. We therefore need to match it against a
// date in the timezone of the user.
const userZonedDate = utcToZonedTime(date, dateDetails.userTimeZone)
const userZonedDate = utcToZonedTime(date, convertTimezoneToOffset(dateDetails.userTimeZone))

// Find a entry that matches the date
const entry = entries.find((entry) => {
Expand Down
14 changes: 14 additions & 0 deletions src/utils/convertTimezoneToOffset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const { getTimezoneOffset, format } = require('date-fns-tz')

const formatMsToOffset = (ms) => {
const isPositive = ms >= 0
const formatted = format(ms, 'hh:mm')
return `${ isPositive ? '+' : '-' }${ formatted }`
}

module.exports = (timezone) => {
const offset = getTimezoneOffset(timezone)
return offset ? formatMsToOffset(offset) : '+00:00'
}
13,117 changes: 6,599 additions & 6,518 deletions yarn.lock

Large diffs are not rendered by default.