Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Fix DateTime to Unix Time in Send-GraphiteMetric #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Functions/Send-GraphiteMetric.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ function Send-GraphiteMetric
# If Received A DateTime Object - Convert To UnixTime
if ($DateTime)
{
$utcDate = $DateTime.ToUniversalTime()

# Convert to a Unix time without any rounding
$UnixTime = [uint64]$DateTime.ToUniversalTime()
[uint64]$UnixTime = [double]::Parse((Get-Date -Date $utcDate -UFormat %s))
}

# Create Send-To-Graphite Metric
Expand All @@ -94,4 +96,4 @@ function Send-GraphiteMetric
}

SendMetrics @sendMetricsParams
}
}