Improved timestamps in logbook

This commit is contained in:
Markus Fleschutz 2020-12-25 10:57:09 +00:00
parent e8e57b8308
commit cfce41d8bd
3 changed files with 8 additions and 10 deletions

View File

@ -1,2 +1,2 @@
UTC,Username,Text Time,User,Text
2020-12-24 09:24:30,mf,Hello World 2020-12-24T09:24:30Z,mf,Hello World

1 UTC Time Username User Text
2 2020-12-24 09:24:30 2020-12-24T09:24:30Z mf mf Hello World

View File

@ -12,11 +12,11 @@ try {
$Table = import-csv "$PathToRepo/Data/Logbook.csv" $Table = import-csv "$PathToRepo/Data/Logbook.csv"
write-output "" write-output ""
write-output "UTC User Text" write-output "Time User Text"
write-output "---------------------------------------------------------------" write-output "---------------------------------------------------------------"
foreach($Row in $Table) { foreach($Row in $Table) {
$Time = $Row.UTC $Time = $Row.Time
$User = $Row.Username $User = $Row.User
$Text = $Row.Text $Text = $Row.Text
write-output "$Time ($User) $Text" write-output "$Time ($User) $Text"
} }

View File

@ -8,16 +8,14 @@
param([String]$Text) param([String]$Text)
try { try {
$Time = Get-Date -format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC
$User = $(whoami)
if ($Text -eq "" ) { if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write" [String]$Text = read-host "Enter text to write"
} }
$Line = "$Time,$User,$Text"
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent $PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
$Timestamp = Get-Date -format "yyyy-MM-dd HH:mm:ss" -AsUTC
$UserName = $(whoami)
$Line = "$Timestamp,$UserName,$Text"
write-output $Line >> "$PathToRepo/Data/Logbook.csv" write-output $Line >> "$PathToRepo/Data/Logbook.csv"
exit 0 exit 0
} catch { } catch {