Skip to content

Commit

Permalink
Display date range when downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
benfoxall committed Apr 9, 2024
1 parent 4b9ee59 commit a2be043
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h1>

<section id="results" rv-show="submitted" style="display:none">
<h1>{ status }</h1>
<h2><small>{date_range | timerange}</small></h2>
<!--p>
<span class="label label-warning">
retries: <span data-bind="retries">-</span>
Expand Down Expand Up @@ -113,6 +114,7 @@ <h4 class="modal-title">Extra Settings</h4>
user_error: false,
complete: false,
errors: 0,
date_range: [null, null],

// settings
api_key:'',
Expand All @@ -126,6 +128,24 @@ <h4 class="modal-title">Extra Settings</h4>
}
};


function extend([min, max], date_str){
if(!date_str) return [min,max]
const date = new Date(date_str)

return [
date < min || min === null ? date : min,
date > max || max === null ? date : max
]
}

let formatter = new Intl.DateTimeFormat(navigator.language, { month: 'short', year: 'numeric' });

rivets.formatters.timerange = function([from, to]) {
if(!(from || to)) return '-'
return formatter.formatRange(from, to)
}

rivets.bind(document, state)


Expand Down Expand Up @@ -191,6 +211,9 @@ <h4 class="modal-title">Extra Settings</h4>
data[item.i] = blb;
bytes+= blb.size;
state.kb = Math.round(bytes/1024);

state.date_range = extend(state.date_range, tracks[0].date)
state.date_range = extend(state.date_range, tracks[tracks.length - 1].date)
})
.fail(function(){
state.errors++;
Expand Down

0 comments on commit a2be043

Please sign in to comment.