Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Point2 class added to support nano and micro seconds insert/get #68

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions InfluxData.Net.Common/Constants/TimeUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ namespace InfluxData.Net.Common.Constants
/// </summary>
public static class TimeUnit
{
// NOTE: currently not supported
//public const string Nanoseconds = "n";
/// <summary>
/// Use this value only with <see cref="Point2"/>
/// </summary>
public const string Nanoseconds = "ns";

// NOTE: currently not supported
//public const string Microseconds = "u";
/// <summary>
/// Use this value only with <see cref="Point2"/>
/// </summary>
public const string Microseconds = "u";

public const string Milliseconds = "ms";

Expand Down
11 changes: 9 additions & 2 deletions InfluxData.Net.InfluxDb/Formatters/PointFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,16 @@ protected virtual string FormatPointField(string key, object value)

protected virtual string FormatPointTimestamp(Point point, string precision = TimeUnit.Milliseconds)
{
return point.Timestamp.HasValue ? point.Timestamp.Value.ToUnixTime(precision).ToString() : string.Empty;
if(point is Point2)
{
return ((Point2)point).UnixTimeStamp.HasValue ? ((Point2)point).UnixTimeStamp.ToString() : string.Empty;
}
else
{
return point.Timestamp.HasValue ? point.Timestamp.Value.ToUnixTime(precision).ToString() : string.Empty;
}
}

protected virtual string ToInt(string result)
{
return $"{result}i";
Expand Down
19 changes: 19 additions & 0 deletions InfluxData.Net.InfluxDb/Models/Point2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace InfluxData.Net.InfluxDb.Models
{
/// <summary>
/// Special case designed to handle UnixTimeStamp and nano seconds
/// Use this class to provide time in micro or nano seconds
/// </summary>
public class Point2 : Point
{
/// <summary>
/// Unix timestamp. Could be in nano seconds
/// If you are using Point2, then UnixTimeStamp will be used and TimeStamp will be ignored
/// </summary>
public long? UnixTimeStamp { get; set; }
}
}