Skip to content
/ Yort.Ntp Public

A cross platform NTP client library for .Net platforms. Allows you to easily retrieve an accurate, current date & time from internet NTP servers.

License

Notifications You must be signed in to change notification settings

Yortw/Yort.Ntp

Repository files navigation

Yort.Ntp.Portable

A cross platform NTP client library for .Net platforms. Allows you to easily retrieve an accurate, current date & time from internet NTP servers.

GitHub license

Supported Platforms

Currently;

  • .Net Framework 4.0+
  • .Net Framework 4.5+ **
  • Windows Phone Silverlight (8.1+)
  • Xamarin.iOS **
  • Xamarin.Android **
  • WinRT (Windows Store Apps 8.1) **
  • UWP 10+ (Windows 10 Universal Programs) **
  • .Net Standard 1.3

** Supports async/await

Build Status

Build status

Available on Nuget

    PM> Install-Package Yort.Ntp.Portable

NuGet Badge

Samples

For platforms that support task based async;

var client = new Yort.Ntp.NtpClient();
var currentTime = await client.RequestTimeAsync();

For platforms that do not support async/await or tasks (or if you don't want to use async/await);

var client = new Yort.Ntp.NtpClient();
client.TimeReceived += Client_TimeReceived;
client.ErrorOccurred += Client_ErrorOccurred;
client.BeginRequestTime();

private void Client_ErrorOccurred(object sender, NtpNetworkErrorEventArgs e)
{
	//TODO: Handle errors here.
}

private void Client_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
{
    //TODO: Use retrieved time here. Time is provided by e.CurrentTime.
	System.Diagnostics.Debug.WriteLine(e.CurrentTime);
}

Attributions

The icon for this project is Computer Time by Arthur Shlain from the Noun Project and is used under the Creative Commons License.

About

A cross platform NTP client library for .Net platforms. Allows you to easily retrieve an accurate, current date & time from internet NTP servers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •