qw/timer (#23)
* Rename logo and add 32x32 version * Set timer icon if a timer is running * Do not query activities on initialization * Show timer in bubble if timed activity exists * Pass timed activity to App * Code cleanup * Show timer view and stop timer * Make hours optional * Use booked seconds instead of hours * Add type submit to form button * Define colors as sass variables⎄ * Style timer view * Show start timer submit label * Update view layouts and content * Update version and changelog * Dyanically set iframe height * Reduce h1 font size * Add svg webpack loader * Parse empty string (TimeInputParser) * Forward ref in Popup component * Start time on current day only, format buttons * Improve styling * Set standard height as iframe default height, validate form * Upgrade packages to supress react warning * Show activity form in popup after timer was stoped * Use stop-watch icon in timer view * Fix empty description * Close TimerView if timer stopped for current service * Style timerview * Improve timer view styling * qw/setting-time-tracking-hh-mm (#24) * Format duration depending on settingTimeTrackingHHMM * Fix formatDuation without second argument * Fix time format after updating bubble * Add tests for formatDuration
This commit is contained in:
@@ -12,7 +12,9 @@ import {
|
||||
pick,
|
||||
head,
|
||||
defaultTo,
|
||||
padCharsStart,
|
||||
} from "lodash/fp"
|
||||
import { startOfWeek, endOfWeek } from "date-fns"
|
||||
import { format } from "date-fns"
|
||||
|
||||
const nilToArray = input => input || []
|
||||
@@ -105,6 +107,8 @@ export const trace = curry((tag, value) => {
|
||||
|
||||
export const weekStartsOn = 1
|
||||
export const formatDate = date => format(date, "yyyy-MM-dd")
|
||||
export const getStartOfWeek = () => startOfWeek(new Date(), { weekStartsOn })
|
||||
export const getEndOfWeek = () => endOfWeek(new Date(), { weekStartsOn })
|
||||
|
||||
export const extensionSettingsUrl = () => `chrome://extensions/?id=${chrome.runtime.id}`
|
||||
|
||||
@@ -120,3 +124,22 @@ export const extractAndSetTag = changeset => {
|
||||
tag: match[1],
|
||||
}
|
||||
}
|
||||
|
||||
export const formatDuration = (
|
||||
durationInSeconds,
|
||||
{ settingTimeTrackingHHMM = true, showSeconds = true } = {},
|
||||
) => {
|
||||
if (settingTimeTrackingHHMM) {
|
||||
const hours = Math.floor(durationInSeconds / 3600)
|
||||
const minutes = Math.floor((durationInSeconds % 3600) / 60)
|
||||
const result = `${hours}:${padCharsStart("0", 2, minutes)}`
|
||||
if (!showSeconds) {
|
||||
return result
|
||||
} else {
|
||||
const seconds = durationInSeconds % 60
|
||||
return result + `:${padCharsStart("0", 2, seconds)}`
|
||||
}
|
||||
} else {
|
||||
return (durationInSeconds / 3600).toFixed(2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user