A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

Overview

TimeZonePicker

Build Status codebeat badge Version License Platform

Buy Me a Coffee at ko-fi.com

A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

Screenshots

Installation

CocoaPods

To install it in your iOS project, install with CocoaPods

pod 'TimeZonePicker'

Usage

Basic Initialisation

To initialise a timeZonePicker you can use the class function getVC(withDelegate: TimeZonePickerDelegate) on the TimeZonePickerViewController as below:

let timeZonePicker = TimeZonePickerViewController.getVC(withDelegate: self)

Then you can use the timeZonePicker as you would any UIViewController, for example:

present(timeZonePicker, animated: true, completion: nil)

TimeZonePickerDelegate

The TimeZonePickerDelegate currently has only one method that needs to be implemented:

func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone)

Once an item is selected from the table of cities/countries the above delegate method gets called, conveniently returning the TimeZonePickerViewController and the selected TimeZone. You can use the timeZonePicker to dismiss it here and the timeZone as you need it in your application. For example:

func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone) {
    timeZoneName.text = timeZone.identifier
    timeZoneOffset.text = timeZone.abbreviation()
    timeZonePicker.dismiss(animated: true, completion: nil)
}

Please check the TimeZonePickerExample project for the above usage example. If you have any questions do not hesitate to get in touch with me.

Requirements

  • iOS 8 or later.
  • Swift 3

License

Copyright (c) 2017 Gligor Kotushevski

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
This Control is a beautiful time-of-day picker heavily inspired by the iOS 10
This Control is a beautiful time-of-day picker heavily inspired by the iOS 10 "Bedtime" timer.

#10Clock Dark and Mysterious πŸ•Ά Light Colors 🌻 Usage The control itsself is TenClock. Add that to your view hierarchy, and constrain it to be square

Better time picker for iOS.

TimePicker Better TimePicker for iOS Requirements Swift 5.0 iOS 10.0+ Xcode 10.2+ Installation The easiest way is through CocoaPods. Simply add the de

Time is a Swift package that makes dealing with calendar values a natural and straight-forward process.

Time Time is a Swift package that makes dealing with calendar values a natural and straight-forward process. Working with calendars can be extremely c

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier.

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier. NVDate is testable and robust, we wrote intensive test to make sure everything is safe.

SwiftDate πŸ” Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
SwiftDate πŸ” Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.

Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift. What's This? SwiftDate is the definitive toolchain to ma

NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.
NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.

TrueTime for Swift Make sure to check out our counterpart too: TrueTime, an NTP library for Android. NTP client for Swift. Calculate the time "now" im

Custom Time Picker ViewController with Selection of start and end times in Swift πŸ”Ά
Custom Time Picker ViewController with Selection of start and end times in Swift πŸ”Ά

LFTimePicker Custom Time Picker ViewController with Selection of start and end times in Swift πŸ”Ά . Based on Adey Salyard's design @ Dribbble One to tw

SwiftUI library to display a clock. You can move the arms to change the time, change the style of the clock and customise some configurations.
SwiftUI library to display a clock. You can move the arms to change the time, change the style of the clock and customise some configurations.

SwiftClockUI Clock UI for SwiftUI This library has been tested βœ… πŸ’» macOS Catalina 10.15.3 βœ… πŸ’» macOS Big Sur 11.6 βœ… πŸ“± iOS 13 βœ… πŸ“± iOS 14 βœ… πŸ“± iOS 15

Swifty Date & Time API inspired from Java 8 DateTime API.

AnyDate Swifty Date & Time API inspired from Java 8 DateTime API. Background I think that date & time API should be easy and accurate. Previous dates,

Comments
  • SwiftUI View

    SwiftUI View

    Here is the pull request for my SwiftUI version of the TimeZonePicker!

    So far, it's worked correctly on macOS. I wasn't able to test it with iOS, unfortunately; for some reason Xcode refused to compile an iOS test app, and it looks like the solution may be to try and reinstall Xcode, which I'm not able to do at the moment. Looking through the code, though, I don't see anything that looks explicitly macOS-specific.

    I also updated the README to include some info on using the SwiftUI view.

    opened by Meorge 9
  • SwiftUI + License for JSON?

    SwiftUI + License for JSON?

    Hi,

    For a project I'm working on, I need a SwiftUI timezone picker and was considering adapting your code/JSON database file to SwiftUI. I haven't seen anything that states the JSON came from another source, so I'm assuming that the answer to this is 'yes', but just in case I wanted to confirm that the CitiesAndTimeZones.json file is licensed under Apache 2.0 with the rest of the code?

    Thanks, Malcolm

    opened by Meorge 6
Owner
Gligor Kotushevski
I am a senior software engineer with professional experience in software development and architecture focusing on mobile apps development.
Gligor Kotushevski
The most perfect Swift Timer you'll ever need.

Timerable ⏰ The most perfect Swift Timer you'll ever need. A protocol-oriented Timer Factory with all the features you'll ever need. I wrote it in bot

Emad Beyrami 24 Dec 22, 2022
Typical master detail SAMPLE application written in Swift to test NY Times Most Popular API

NYTimes-Demo: Typical master detail SAMPLE application written in Swift to test NY Times Most Popular API. This SAMPLE application is written in Swift

Atif Naveed 0 Nov 3, 2021
This app will hlep you realize if the job you are doing, truly is worth your time

Worth Your Time Is working for your current pay really worth your time? This app will hlep you realize if the job you are doing, truly is worth your t

Phillip Lundin 2 Mar 1, 2022
Time Lines - Know when all your friends, colleagues, and family are

Time Lines Know when all your friends, colleagues, and family are. Time Lines is a practical app to know when all your friends, colleagues and family

Mathieu Dutour 50 Dec 14, 2022
The goal is a simple iOS app that draws an analog clock of the current time

Qrono This is a work-in-progress. The goal is a simple iOS app that draws an analog clock of the current time (as well as displaying a digital readout

Justin Reusch 2 Jan 29, 2022
A basic countdown app that allows the user to create, edit, and delete events. Each event contains a live countdown timer to a specified date and time.

Event Countdown App (iOS) Created by Lucas Ausberger About This Project Created: January 4, 2021 Last Updated: January 8, 2021 Current Verison: 1.1.1

Lucas Ausberger 1 Jan 8, 2022
Simple clock app for the different time zones.

DunyaSaatleri The clock app provide the user adding clocks of cities from different timezones. The times showed by analog clock. The added clocks can

Ozan Barış GÜNAYDIN 1 Nov 27, 2021
SwiftMoment - A time and calendar manipulation library for iOS 9+, macOS 10.11+, tvOS 9+, watchOS 2+ written in Swift 4.

SwiftMoment This framework is inspired by Moment.js. Its objectives are the following: Simplify the manipulation and readability of date and interval

Adrian Kosmaczewski 1.6k Dec 31, 2022
Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS.

Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS. Installation Timekee

Andreas Pfurtscheller 1 Oct 18, 2021
Date and time manager for iOS/OSX written in Swift

Tempo was designed to work both in OSX and in iOS (7.0+). Work with the time or dates can be cumbersome, iOS development. Tempo allows you to deal easly with date and time. Basics manipulations are already implemented in Tempo.

Remi ROBERT 153 Jun 3, 2021