Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit c8fa6db

Browse files
committed
adopt the macOS screenshot file name
Fixes #626
1 parent d703f4b commit c8fa6db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/plugins/ui/commands/screenshot.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ const _squish = (which, op) => {
8484
const squish = which => _squish(which, (element, property, value) => element.style[property] = value)
8585
const unsquish = which => _squish(which, (element, property, value) => element.style[property] = null)
8686

87+
/** fill to two digits */
88+
const fill = n => n < 10 ? `0${n}` : n
89+
90+
/** format the date; e.g. 2018-03-27 */
91+
const dateString = ts => `${ts.getUTCFullYear()}-${fill(1 + ts.getUTCMonth())}-${fill(ts.getUTCDate())}`
92+
93+
/** format the time; e.g. 11.36.54 AM */
94+
const timeString = ts => ts.toLocaleTimeString('en-us').replace(/:/g, '.')
8795

8896
/** this is the handler body */
8997
module.exports = (commandTree, prequire) => {
@@ -203,7 +211,7 @@ module.exports = (commandTree, prequire) => {
203211
// save screenshot to disk
204212
const saveButton = document.createElement('div'),
205213
ts = new Date(),
206-
filename = `Screen Shot ${ts.toLocaleDateString().replace(/\//g,'-')}-${ts.toLocaleTimeString().replace(/:/g,'-')}.png`,
214+
filename = `Screen Shot ${dateString(ts)} ${timeString(ts)}.png`,
207215
location = require('path').join(app.getPath('desktop'), filename)
208216
saveButton.innerText = 'Save to Desktop'
209217
saveButton.className = 'sidecar-bottom-stripe-button sidecar-bottom-stripe-save'

0 commit comments

Comments
 (0)