diff --git a/README.md b/README.md
index 873df9a..93e17ad 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,12 @@ Then go ahead and consume it.
var zodiacSign = Zodiac.GetZodiacSignForDate(new DateTime(1950, 2, 12));
```
+Another simpler option if all you need is the zodiac sign for a single date is:
+```C#
+var givenDateTime = new DateTime(1995, 8, 26);
+var zodiacSign = givenDateTime.GetZodiacSign();
+```
+
#### More examples
[Horoscope.Zodiac](https://github.com/ClydeDz/horoscope-nuget/blob/master/Src/Horoscope.TestConsole/ZodiacExamples.cs)
[Horoscope.ChineseZodiac](https://github.com/ClydeDz/horoscope-nuget/blob/master/Src/Horoscope.TestConsole/ChineseZodiacExamples.cs)
diff --git a/Src/Horoscope.TestConsole/ChineseZodiacExamples.cs b/Src/Horoscope.TestConsole/ChineseZodiacExamples.cs
index d3fa5fe..48ef989 100644
--- a/Src/Horoscope.TestConsole/ChineseZodiacExamples.cs
+++ b/Src/Horoscope.TestConsole/ChineseZodiacExamples.cs
@@ -28,6 +28,11 @@ public static void ShowZodiacBasicExamples()
var zodiacSignForDate = ChineseZodiac.GetZodiacSignForDate(new DateTime(1966, 2, 12));
Console.WriteLine($"\nChinese zodiac sign for {new DateTime(1966, 2, 12).ToShortDateString()} is {zodiacSignForDate.ZodiacEnglishTranslation}");
+ // Another option would be:
+ var givenDate = new DateTime(1995, 8, 26);
+ var anotherZodiacSign = givenDate.GetChineseZodiacSign();
+ Console.WriteLine($"\nChinese zodiac sign for {givenDate.ToShortDateString()} is {anotherZodiacSign.ZodiacEnglishTranslation}");
+
var allChineseZodiacSigns = ChineseZodiac.GetAllZodiacSigns();
Console.WriteLine($"\nGet a list of all Chinese zodiac signs");
foreach (var currentZodiacSign in allChineseZodiacSigns)
diff --git a/Src/Horoscope.TestConsole/ZodiacExamples.cs b/Src/Horoscope.TestConsole/ZodiacExamples.cs
index bfa6af5..745d5b6 100644
--- a/Src/Horoscope.TestConsole/ZodiacExamples.cs
+++ b/Src/Horoscope.TestConsole/ZodiacExamples.cs
@@ -16,6 +16,12 @@ public static void ShowZodiacBasicExamples()
Console.WriteLine($"\nZodiac details for {new DateTime(1966, 2, 12).ToShortDateString()}");
Console.WriteLine($"Name: {zodiacSign.ZodiacName} English name: {zodiacSign.ZodiacEnglishTranslation} Duration: {zodiacSign.ZodiacDuration}");
+ // Another option would be:
+ var givenDate = new DateTime(1995, 8, 26);
+ var anotherZodiacSign = givenDate.GetZodiacSign();
+ Console.WriteLine($"\nZodiac details for {givenDate.ToShortDateString()}");
+ Console.WriteLine($"Name: {anotherZodiacSign.ZodiacName} English name: {anotherZodiacSign.ZodiacEnglishTranslation} Duration: {anotherZodiacSign.ZodiacDuration}");
+
var capriconZodiacSign = Zodiac.GetZodiacSign(ZodiacSigns.Capricorn);
Console.WriteLine($"\nZodiac duration for {ZodiacSigns.Capricorn}");
Console.WriteLine(capriconZodiacSign.ZodiacDuration);
diff --git a/Src/Horoscope.Tests/DateTimeExtensionsTest.cs b/Src/Horoscope.Tests/DateTimeExtensionsTest.cs
new file mode 100644
index 0000000..f63bed3
--- /dev/null
+++ b/Src/Horoscope.Tests/DateTimeExtensionsTest.cs
@@ -0,0 +1,33 @@
+using System;
+using Horoscope.Extensions;
+using Xunit;
+
+namespace Horoscope.Tests
+{
+ public class DateTimeExtensionsTest
+ {
+ [Theory]
+ [InlineData(2, 12, "Aquarius")]
+ [InlineData(3, 3, "Pisces")]
+ [InlineData(2, 28, "Pisces")]
+ [InlineData(10, 23, "Scorpio")]
+ public void GetZodiacSign_Test(int month, int day, string zodiacSign)
+ {
+ var dateTime = new DateTime(1950, month, day);
+ var symbol = dateTime.GetZodiacSign();
+ Assert.Equal(zodiacSign, symbol.ZodiacName);
+ }
+
+ [Theory]
+ [InlineData(2018, "Dog")]
+ [InlineData(1952, "Dragon")]
+ [InlineData(1969, "Rooster")]
+ [InlineData(1903, "Rabbit")]
+ public void GetChineseZodiacSign_Test(int year, string zodiacSign)
+ {
+ var dateTime = new DateTime(year, 4, 1);
+ var symbol = dateTime.GetChineseZodiacSign();
+ Assert.Equal(zodiacSign, symbol.ZodiacEnglishTranslation);
+ }
+ }
+}
diff --git a/Src/Horoscope.Tests/Horoscope.Tests.csproj b/Src/Horoscope.Tests/Horoscope.Tests.csproj
index ad5f0a1..16ba751 100644
--- a/Src/Horoscope.Tests/Horoscope.Tests.csproj
+++ b/Src/Horoscope.Tests/Horoscope.Tests.csproj
@@ -59,6 +59,7 @@
+
diff --git a/Src/Horoscope.nuspec b/Src/Horoscope.nuspec
index ca2703f..07f9be3 100644
--- a/Src/Horoscope.nuspec
+++ b/Src/Horoscope.nuspec
@@ -2,7 +2,7 @@
Horoscope
- 1.0.0
+ 1.1.0
Horoscope
Clyde D'Souza
Clyde D'Souza
@@ -14,7 +14,7 @@
https://raw.githubusercontent.com/ClydeDz/horoscope-nuget/master/Icon.png
A .NET library for zodiac signs. Get details on each zodiac sign, pass a date and know which zodiac sign it falls in or get a list of all zodiac signs. Now includes Chinese zodiac signs and elements!
A .NET library for zodiac signs. Get details on each zodiac sign, pass a date and know which zodiac sign it falls in or get a list of all zodiac signs.
- Enable publicy visible comments. Add contributing guidelines and a pull request template to the GitHub repository. Use new icon format. More release notes here: https://github.com/ClydeDz/horoscope-nuget/releases
+ Add extension methods option to DateTime objects to enable simpler, easier access to the Zodiac Signs.
Copyright (c) 2018 Clyde D'Souza
horoscope zodiac development library zodiac-signs chinese-zodiac chinese-horoscope yinyang chinese-elements yin-yang
diff --git a/Src/Horoscope/DateTimeExtensions.cs b/Src/Horoscope/DateTimeExtensions.cs
new file mode 100644
index 0000000..3d04457
--- /dev/null
+++ b/Src/Horoscope/DateTimeExtensions.cs
@@ -0,0 +1,25 @@
+using Horoscope.Model;
+using System;
+
+namespace Horoscope
+{
+ ///
+ /// Enable usage of Zodiac and ChineseZodiac methods straight from DateTime instances
+ ///
+ public static class DateTimeExtensions
+ {
+ ///
+ /// Gets the zodiac sign.
+ ///
+ /// The date for which you want the zodiac sign.
+ /// A zodiac sign object.
+ public static ZodiacModel GetZodiacSign(this DateTime dateTime) => Zodiac.GetZodiacSignForDate(dateTime);
+
+ ///
+ /// Get the Chinese zodiac sign.
+ ///
+ /// The date you want to query.
+ /// Returns a Chinese zodiac sign object.
+ public static ChineseZodiacModel GetChineseZodiacSign(this DateTime dateTime) => ChineseZodiac.GetZodiacSignForDate(dateTime);
+ }
+}
diff --git a/Src/Horoscope/Extensions/DateTimeExtensions.cs b/Src/Horoscope/Extensions/DateTimeExtensions.cs
new file mode 100644
index 0000000..bfb0444
--- /dev/null
+++ b/Src/Horoscope/Extensions/DateTimeExtensions.cs
@@ -0,0 +1,22 @@
+using Horoscope.Model;
+using System;
+
+namespace Horoscope.Extensions
+{
+ public static class DateTimeExtensions
+ {
+ ///
+ /// Gets the zodiac sign for the date supplied.
+ ///
+ /// The date for which you want the zodiac sign.
+ /// A zodiac sign object.
+ public static ZodiacModel GetZodiacSign(this DateTime dateTime) => Zodiac.GetZodiacSignForDate(dateTime);
+
+ ///
+ /// Get the Chinese zodiac sign for the supplied date.
+ ///
+ /// The date you want to query.
+ /// Returns a Chinese zodiac sign object.
+ public static ChineseZodiacModel GetChineseZodiacSign(this DateTime dateTime) => ChineseZodiac.GetZodiacSignForDate(dateTime);
+ }
+}
diff --git a/Src/Horoscope/Horoscope.csproj b/Src/Horoscope/Horoscope.csproj
index dd7c4ee..204f268 100644
--- a/Src/Horoscope/Horoscope.csproj
+++ b/Src/Horoscope/Horoscope.csproj
@@ -5,7 +5,7 @@
Clyde D'Souza
false
Horoscope
- 1.0.0
+ 1.1.0
https://github.com/ClydeDz/horoscope-nuget
@@ -13,9 +13,9 @@
horoscope zodiac development library zodiac-signs chinese-zodiac chinese-horoscope yinyang chinese-elements yin-yang
A .NET library for zodiac signs. Get details on each zodiac sign, pass a date and know which zodiac sign it falls in or get a list of all zodiac signs. Now includes Chinese zodiac signs and elements!
Copyright (c) 2018 Clyde D'Souza
- Enable publicy visible comments. Add contributing guidelines and a pull request template to the GitHub repository. Use new icon format. More release notes here: https://github.com/ClydeDz/horoscope-nuget/releases
- 1.0.0.0
- 1.0.0.0
+ Add extension methods option to DateTime objects to enable simpler, easier access to the Zodiac Signs.
+ 1.1.0.0
+ 1.1.0.0
Horoscope
true