WorldTimeAPI-ios is a Swift package that provides a convenient way to interact with the WorldTime API. It allows iOS developers to easily fetch current time information for various timezones in their applications.
Note
WorldTimeAPI-ios utilizes the WorldTime API. For detailed information and documentation about the WorldTime API, please refer to the following link: WorldTime API Documentation
You can add WorldTimeAPI-ios to your project using Swift Package Manager. In Xcode, go to File > Swift Packages > Add Package Dependency and enter the repository URL:
https://github.com/Take111/WorldTimeAPI-ios.git
Alternatively, you can add it to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/Take111/WorldTimeAPI-ios.git", from: "0.1.0")
]
Here's a quick example of how to use WorldTimeAPI-ios in your project:
import WorldTimeAPIiOS
let client = WorldTimeClient()
// Fetch current time for a specific timezone
do {
let currentTime = try await client.fetchCurrentTime(with: .etc(.utc))
print("Current UTC time: \(currentTime.datetime)")
} catch {
print("Error fetching time: \(error)")
}
// Fetch current UTC time as a TimeInterval
do {
if let timeInterval = try await client.fetchUTCDateTimeInterval() {
print("Current UTC time interval: \(timeInterval)")
}
} catch {
print("Error fetching UTC time interval: \(error)")
}
// Fetch current UTC time as a Date
do {
if let date = try await client.fetchUTCDateTime() {
print("Current UTC date: \(date)")
}
} catch {
print("Error fetching UTC date: \(error)")
}
Contributions to WorldTimeAPI-ios are welcome! Here's how you can contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the project's coding style.
This project is licensed under the MIT License. However, please note that the API used in this project belongs to WorldTimeAPI. Be sure to check the WorldTimeAPI's terms and conditions for usage of their API.