Skip to content

Commit

Permalink
fix(timeSheetExport): allow for custom date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Mar 6, 2018
1 parent 2ae102f commit fe03021
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -38,7 +38,10 @@ <h2>Time Sheet Export</h2>
<dd>The current time. Could be used for the for the end time of todays working day It's possible to round this via the options.</dd>

<dt>{date}</dt>
<dd>Todays date in standard format (dd/mm/yyyy)</dd>
<dd>Todays date in standard format (mm/dd/yyyy)</dd>

<dt>{date:DD/MM/YYYY} (example)</dt>
<dd>Date with a custom date format string.</dd>

<dt>{taskTitles}</dt>
<dd>Comma separated (parent) task titles</dd>
Expand Down
13 changes: 13 additions & 0 deletions app-src/scripts/dialogs/time-sheet-export/time-sheet-export-c.js
Expand Up @@ -94,6 +94,11 @@

function replaceVals(defaultVal) {
const dVal = defaultVal.trim();

if (dVal.match(/\{date:/)) {
return getCustomDate(dVal);
}

switch (dVal) {
case '{startTime}':
return getStartTime();
Expand Down Expand Up @@ -142,6 +147,14 @@
}
}

function getCustomDate(dVal) {
const dateFormatStr = dVal
.replace('{date:', '')
.replace('}', '')
.trim();
return window.moment().format(dateFormatStr);
}

function getStartTime() {
const val = $rootScope.r.startedTimeToday;
const roundTo = vm.opts.roundStartTimeTo;
Expand Down

0 comments on commit fe03021

Please sign in to comment.