Yort.Ntp Save

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

Project README

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.

Open Source Agenda is not affiliated with "Yort.Ntp" Project. README Source: Yortw/Yort.Ntp
Stars
41
Open Issues
4
Last Commit
5 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating