KayuSoft.WorldTimeAPI 1.0.0

dotnet add package KayuSoft.WorldTimeAPI --version 1.0.0                
NuGet\Install-Package KayuSoft.WorldTimeAPI -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KayuSoft.WorldTimeAPI" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KayuSoft.WorldTimeAPI --version 1.0.0                
#r "nuget: KayuSoft.WorldTimeAPI, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install KayuSoft.WorldTimeAPI as a Cake Addin
#addin nuget:?package=KayuSoft.WorldTimeAPI&version=1.0.0

// Install KayuSoft.WorldTimeAPI as a Cake Tool
#tool nuget:?package=KayuSoft.WorldTimeAPI&version=1.0.0                

WorldTimeAPI

A world time fetcher by timezone or ip, based on https://worldtimeapi.org/ web api service.

(Class) WorldTime

Main class to fetch world time by timezone and ip.

      Methods

            public static WorldTime ByTimezone(Timezone timezone)

                Get world time by specific timezone.
                timezone Specific timezone enum.
                returns: A new world time object.

              Example:

                 WorldTime worldTimeByTimezone = WorldTime.ByTimezone(Timezone.AMERICA_LOS_ANGELES);
                 Console.WriteLine($"Datetime: {worldTimeByTimezone.Datetime}");
                 //Datetime: 2023-03-31T20:40:34.472648-07:00

            public static WorldTime ByTimezone(string timezone)

                Get world time by specific timezone.
                timezone Specific timezone string.
                returns: A new world time object.

              Example:

                 WorldTime worldTimeByTimezone = WorldTime.ByTimezone("America/Los_Angeles");
                 Console.WriteLine($"Datetime: {worldTimeByTimezone.Datetime}");
                 //Datetime: 2023-03-31T20:40:34.472648-07:00

            public static WorldTime ByIP()

                Get world time by your current IP.
                returns: A new world time object.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"Datetime: {worldTimeByCurrentIP.Datetime}");
                 //Datetime: 2023-04-01T06:40:34.567288+03:00

            public static WorldTime ByIP(string ip)

                Get world time by specific IP.
                ip Specific IP.
                returns: A new world time object.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP("8.8.8.8");
                 Console.WriteLine($"Datetime: {worldTimeByCurrentIP.Datetime}");
                 //Datetime: 2023-03-31T22:40:34.670224-05:00

      Properties

            public string Abbreviation { get; private set; }

                The abbreviated name of the timezone.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"Abbreviation: {worldTimeByTimezone.Abbreviation}");
                 //Abbreviation: +03

            public string ClientIP { get; private set; }

                IPv4 address of the client.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"ClientIP: {worldTimeByTimezone.ClientIP}");
                 //ClientIP: XX.XXX.XXX.XXX

            public string Datetime { get; private set; }

                An ISO8601-valid string representing the current, local date/time.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"Datetime: {worldTimeByCurrentIP.Datetime}");
                 //Datetime: 2023-04-01T06:40:34.567288+03:00

            public int DayOfWeek { get; private set; }

                Current day number of the week, where sunday is 0.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"DayOfWeek: {worldTimeByTimezone.DayOfWeek}");
                 //DayOfWeek: 6

            public int DayOfYear { get; private set; }

                Ordinal date of the current year.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"DayOfYear: {worldTimeByTimezone.DayOfYear}");
                 //DayOfYear: 91

            public bool Dst { get; private set; }

                Flag indicating whether the local time is in daylight savings.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"Dst: {worldTimeByTimezone.Dst}");
                 //Dst: False

            public string DstFrom { get; private set; }

                An ISO8601-valid string representing the datetime when daylight savings started for this timezone.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"DstFrom: {worldTimeByTimezone.DstFrom}");
                 //DstFrom: 2023-03-12T10:00:00+00:00

            public int DstOffset { get; private set; }

                The difference in seconds between the current local time and daylight saving time for the location.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"DstOffset: {worldTimeByTimezone.DstOffset}");
                 //DstOffset: 3600

            public string DstUntil { get; private set; }

                An ISO8601-valid string representing the datetime when daylight savings will end for this timezone.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"DstUntil: {worldTimeByTimezone.DstUntil}");
                 //DstUntil: 2023-11-05T09:00:00+00:00

            public int RawOffset { get; private set; }

                The difference in seconds between the current local time and the time in UTC, excluding any daylight saving difference (see DstOffset).

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"RawOffset: {worldTimeByTimezone.RawOffset}");
                 //RawOffset: 10800

            public string Timezone { get; private set; }

                Timezone in Area/Location or Area/Location/Region format.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"Timezone: {worldTimeByTimezone.Timezone}");
                 //Timezone: Europe/Istanbul

            public int UnixTime { get; private set; }

                Number of seconds since the Epoch.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"UnixTime: {worldTimeByTimezone.UnixTime}");
                 //UnixTime: 1680320434

            public string UtcDatetime { get; private set; }

                An ISO8601-valid string representing the current date/time in UTC.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"UtcDatetime: {worldTimeByTimezone.UtcDatetime}");
                 //UtcDatetime: 2023-04-01T03:40:34.567288+00:00

            public string UtcOffset { get; private set; }

                An ISO8601-valid string representing the offset from UTC.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"UtcOffset: {worldTimeByTimezone.UtcOffset}");
                 //UtcOffset: +03:00

            public int WeekNumber { get; private set; }

                The current week number.

              Example:

                 WorldTime worldTimeByCurrentIP = WorldTime.ByIP();
                 Console.WriteLine($"WeekNumber: {worldTimeByTimezone.WeekNumber}");
                 //WeekNumber: 13

      Exceptions

            public UnknownLocationException(string message)

                It is thrown when when timezone is not valid.

              Example:

<pre> try { Console.WriteLine("WorldTime.ByTimezone("Pacific/LOST_Island")"); WorldTime.ByTimezone("Pacific/LOST_Island"); } catch (UnknownLocationException ex) { Console.WriteLine($"UnknownLocationException: {ex.Message}"); } </pre>

                 //WorldTime.ByTimezone("Pacific/LOST_Island")
                 //UnknownLocationException: unknown location Pacific/LOST_Island

            public MalformedIPException(string message)

                It is thrown when when IP is malformed.

              Example:

<pre> try { Console.WriteLine("WorldTime.ByIP("192.168.1.1")"); WorldTime.ByIP("192.168.1.1"); } catch (MalformedIPException ex) { Console.WriteLine($"MalformedIPException: {ex.Message}"); } </pre>

                 //WorldTime.ByIP("192.168.1.1")
                 //MalformedIPException: malformed ip

More Information

For more information please visit following pages:

https://worldtimeapi.org/\ https://worldtimeapi.org/pages/examples\ https://worldtimeapi.org/pages/schema\ https://worldtimeapi.org/api\ https://worldtimeapi.org/pages/faqs

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 215 4/1/2023