Swap to getting date in seconds since BSD date doesn't support nanos

This commit is contained in:
David Dworken 2022-04-18 22:36:57 -07:00
parent ca1987a9ab
commit 76f12ab64a
4 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@ function PreCommand() {
unset HISHTORY_AT_PROMPT unset HISHTORY_AT_PROMPT
# Run before every command # Run before every command
HISHTORY_START_TIME=`date +%s%N` HISHTORY_START_TIME=`date +%s`
} }
trap "PreCommand" DEBUG trap "PreCommand" DEBUG

View File

@ -8,7 +8,7 @@ function _hishtory_add() {
# Runs after <ENTER>, but before the command is executed # Runs after <ENTER>, but before the command is executed
# $1 contains the command that was run # $1 contains the command that was run
_hishtory_command=$1 _hishtory_command=$1
_hishtory_start_time=`date +%s%N` _hishtory_start_time=`date +%s`
} }
function _hishtory_precmd() { function _hishtory_precmd() {

View File

@ -88,11 +88,11 @@ func BuildHistoryEntry(args []string) (*data.HistoryEntry, error) {
entry.CurrentWorkingDirectory = cwd entry.CurrentWorkingDirectory = cwd
// start time // start time
nanos, err := parseCrossPlatformInt(args[5]) seconds, err := parseCrossPlatformInt(args[5])
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to parse start time %s as int: %v", args[5], err) return nil, fmt.Errorf("failed to parse start time %s as int: %v", args[5], err)
} }
entry.StartTime = time.Unix(0, nanos) entry.StartTime = time.Unix(seconds, 0)
// end time // end time
entry.EndTime = time.Now() entry.EndTime = time.Now()

View File

@ -9,7 +9,7 @@ function PreCommand() {
unset HISHTORY_AT_PROMPT unset HISHTORY_AT_PROMPT
# Run before every command # Run before every command
HISHTORY_START_TIME=`date +%s%N` HISHTORY_START_TIME=`date +%s`
} }
trap "PreCommand" DEBUG trap "PreCommand" DEBUG