mirror of https://github.com/bobwen-dev/htpdate
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'
This commit is contained in:
parent
cddb7daecb
commit
8ee35d8541
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue