Skip to content

Commit

Permalink
Merge pull request #30 from jonez1/feature/issue-29-manage-time
Browse files Browse the repository at this point in the history
Merged feature/issue #30
  • Loading branch information
danniehansen authored Mar 5, 2021
2 parents 34c38cc + 0c97aaf commit deee1bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ function formatTime (secondsToFormat, allowSeconds) {
*
* @returns {string}
*/
function formatDate (date) {
function formatDate (date, returnOnlyTimeString) {
returnOnlyTimeString = returnOnlyTimeString || false;

const dateStr = [
date.getFullYear(),
((date.getMonth() + 1) < 10 ? '0' : '') + (date.getMonth() + 1),
Expand All @@ -316,7 +318,7 @@ function formatDate (date) {
(date.getMinutes() < 10 ? '0' : '') + date.getMinutes()
];

return dateStr.join('-') + ' ' + timeStr.join(':');
return (returnOnlyTimeString ? '' : dateStr.join('-') + ' ') + timeStr.join(':');
}

/**
Expand Down Expand Up @@ -623,11 +625,14 @@ function cardButtons (t) {
memberRanges.forEach((range) => {
const start = new Date(range.item.start * 1000);
const end = new Date(range.item.end * 1000);
const rangeOnTheSameDay = start.toDateString() === end.toDateString();
const rangeLengthInSeconds = range.item.end - range.item.start;

const _rangeIndex = range.rangeIndex;
const _range = range;

items.push({
text: formatDate(start) + ' - ' + formatDate(end),
text: formatDate(start) + ' - ' + formatDate(end, rangeOnTheSameDay) + ' ('+ formatTime(rangeLengthInSeconds, false) +')',
callback: function (t) {
return t.popup({
title: 'Edit time range',
Expand Down
2 changes: 1 addition & 1 deletion src/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ input[type="range"] {

label {
user-select: none;
}
}

0 comments on commit deee1bb

Please sign in to comment.