Skip to content

Commit eb062a2

Browse files
committed
add example of how to init with Swift Date
1 parent d0c64ec commit eb062a2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

README.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ This is a Swift Package that will:
99
1. For Swift devs: Service requests specifying a date as a parameter, responding with the Chinese zodiac's Associated element and Associated animal
1010
2. For non-Swift devs: Publish a programmer-friendly JSON file containing all the data mentioned below
1111

12-
## Current status
13-
14-
*Complete!*
15-
1612

1713
## What? Sexa-wha?
1814

@@ -26,13 +22,27 @@ A Sexagenary Cycle is a sixty-year cycle, historically used for recording time i
2622
Pass your birthday as a String (format: MM-DD-YYYY) as a paramter to the `ZodiacQuery` initializer.
2723

2824
```swift
29-
3025
import SexagenaryCycle1924
3126

3227
let query = try! ZodiacQuery(birthday: "11-26-1978")
33-
print(query.animal) // ".Horse"
28+
print(query.animal.name) // ".Horse"
3429
```
3530

31+
Or query with a Swift `Date`!
32+
33+
```swift
34+
import SexagenaryCycle1924
35+
36+
let formatter = DateFormatter()
37+
formatter.dateFormat = "MM-dd-yyyy"
38+
formatter.timeZone = TimeZone.current
39+
let date = formatter.date(from: "10-31-1947")
40+
41+
let query = try! ZodiacQuery(date: date)
42+
print(query.animal.name) // ".Ox"
43+
```
44+
45+
3646
### Other properties
3747

3848
In addition to your Chinese animal sign, there is additional information unique to your year of birth such as Element, Heavenly Stem, and Earthly Branch. Here's the struct:

0 commit comments

Comments
 (0)