From 8ee35d8541e3e094cc9317511dcb5b6f49ca4466 Mon Sep 17 00:00:00 2001 From: Bob Wen Date: Thu, 4 Nov 2021 13:31:33 +0800 Subject: [PATCH] fix bug: windows shell command Strange permission requirements invalidate the wmic command, so when adjusting the time, user need to specify the time format for their region, default command is '[time ]HH[:]mm[:]ss[.]SS[ && date ]MM[-]DD[-]YY', which means 'time HH:mm:ss.SS && date MM-DD-YY' --- adjust_time.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adjust_time.coffee b/adjust_time.coffee index 94db116..9644830 100644 --- a/adjust_time.coffee +++ b/adjust_time.coffee @@ -1,7 +1,7 @@ util = require 'util' { spawn } = require 'child_process' dayjs = require 'dayjs' -dayjs.extend require 'dayjs/plugin/utc' +dayjs.extend require './dayjs_format_ms' platform = require('os').platform() @@ -25,14 +25,14 @@ adjust_time = (delta) -> await wait_data() if platform in ['win32'] cb p... await wait_data() if platform in ['win32'] - cmd = dayjs().add(delta, 'ms').utc().format adjust_time.command + cmd = dayjs().add(delta, 'ms').format adjust_time.command await input_line cmd await input_line 'exit' COMMANDS = { - win32: '[wmic os set localdatetime=]YYYYMMDDHHmmss[.]SSS[000][+000]' - linux: '[date --utc -s ]YYYY[-]MM[-]DDTHH[:]mm[:]ss[.]SSS' + win32: '[time ]HH[:]mm[:]ss[.]SS[ && date ]MM[-]DD[-]YY' + linux: '[date -s ]YYYY[-]MM[-]DDTHH[:]mm[:]ss[.]SSS' } adjust_time.command = COMMANDS[platform] or COMMANDS.linux