• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⌚ 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.

How to use it ?

You can build a new Tempo, with severals way:

var birthdayTempo = Tempo { (newTemp) -> () in
    newTemp.years = 2014
    newTemp.months = 12
    newTemp.days = 12
}
var currentTime = Tempo()
var tempoWithDate = Tempo(date: customNSDate)
var tempoWithString = Tempo(stringDate: "12/02/1992")
var tempoCustomFormat = Tempo(stringDate: "12/02/1992", "dd/MM/yyyy")

Convert Tempo to string, with specific format: All the basics format work with Tempo.

Tempo().format()                                // "2014 12 12 00:00:00"
Tempo().format("yyyy MM dd")                    // "2014 12 12"
Tempo().format("dd EE / MMMM / yyyy")           // "12 Fri / December / 2014"

let t1 = Tempo(stringDate: "2014 12 12")

//change the locale date
t1.locale = NSLocale(localeIdentifier: "fr_FR")
t1.format(format: "EEEE")                       // "mercredi"

t1.locale = NSLocale(localeIdentifier: "en_EN")
t1.format(format: "EEEE")                       // "Wednesday"

t1.locale = NSLocale(localeIdentifier: "es_ES")
t1.format(format: "EEEE")                       // "miércoles"

With Tempo you have access to the date components and the date itself: The date components and the date are linked.

let t = Tempo()

t.years! += 1
t.days! += 20

t.date = NSDate()

You can also make simple comparaison between two Tempo or with NSDate:

var newDate = Tempo { (newTemp) -> () in
  newTemp.years = 2014
  newTemp.months = 10
  newTemp.days = 12
  newTemp.minutes = 2
}

println("newDate: \(newDate.formatDate())")             // "2014 10 12 00:02:00"
println("current time : \(Tempo().formatDate())")       // "2014 12 18 15:40:11"

Tempo().isAfter(newDate)                                // "True"
Tempo().isBefore(newDate)                               // "False"
Tempo().isSame(newDate)                                 // "False"
Tempo().isBetween(tempoLeft:newDate, tempoRight:d2)     // "True"

Tempo().isToday(newDate)                                // "False"
Tempo().isThisMonth(newDate)                            // "true"
Tempo().isThisYear(newDate)                             // "true"

Tempo also override operator the simple comparaison :

// same as tempo1.isBefore(tempo2)
if tempo1 < tempo2 {
}

// same as tempo1.isAfter(tempo2)
if tempo1 > tempo2 {
}

// same as tempo1.isSame(tempo2)
if tempo1 == tempo2 {
}

// You can add two tempo together:
let result: Tempo = tempo1 + tempo2
let result: Tempo = tempo1 - tempo2

Know difference between two date component:

var newDate = Tempo { (newTemp) -> () in
  newTemp.years = 2014
  newTemp.months = 10
  newTemp.days = 12
  newTemp.minutes = 2
}

Tempo().diffYear(newDate)                  // "0"
Tempo().diffMonth(newDate)                // "-4"
Tempo().diffWeek(newDate)                // "-18"
Tempo().diffDay(newDate)                // "-130"

Get time ago from date or current time: Return literal string with the difference between two Tempo. Can be usefull in for display in message or feeds. You have three diferent kind of display.

var date = Tempo { (newTemp) -> () in
    newTemp.years = 2014
    newTemp.months = 10
    newTemp.days = 25
}

// Classic display
date.timeAgoNow()                       // "3 months ago"
date.timeAgo(Tempo())

// Short display
date.timeAgoSimpleNow()                 // "3mo"
date.timeAgoSimple(Tempo())

// More readable display
date.dateTimeUntilNow()                 // "This year"
date.dateTimeUntil(Tempo())

License

The MIT License (MIT)
Copyright (c) 2014 rémi ROBERT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

Dotzu

📱👀 In-App iOS Debugging Tool With Enhanced Logging, Networking Info, Crash reporting And More.
Swift
1,797
star
2

CameraEngine

🐒📷 Camera engine for iOS, written in Swift, above AVFoundation. 🐒
Swift
583
star
3

RRTagController

🔦 RRTagController allows user to select tag and create new one.
Swift
226
star
4

RRMessageController

📱📝 RRMessageController is a UIViewController, allows you to write a message with photos as attachment.
Objective-C
216
star
5

Facemotion

👀 Face detection and recognition iOS app with OpenCV
Objective-C++
173
star
6

Kinder

👫 🔥 The basics of a Tinder-like swipeable cards interface controller
Swift
171
star
7

TextDrawer

TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage
Swift
106
star
8

Anim

👀 Animation library, using Core Animation. Designed for iOS.
Swift
83
star
9

Github-contributions

🐱 GitHub contributions app, for iOS, WatchOS, and OSX
Swift
75
star
10

RRMaterialNavigationBar

Custom UINavigationBar with Google Material style, for iOS written on Swift.
Swift
75
star
11

ProducthuntOSX

Product hunt application for OS X
Swift
61
star
12

Camembert

Use sqlite3 for iOS and OS X simply.
Swift
51
star
13

gif-creator-ios

iOS Application for create animated gif with the library photos
Objective-C
36
star
14

MVVMBaseProject

Base project to start new app (extremely) quickly, with MVVM architecture. 项目(使用MVVM结构)基于App极速启动
Swift
33
star
15

Crackers

Simple network library in Swift, for iOS and OSX
Swift
31
star
16

Suitchi

Custom Switch for iOS.
Swift
31
star
17

Dotzu-Objective-c

Dotzu Objective-c example project
Objective-C
30
star
18

RRCamera

RRCamera is a camera handler for iOS with crop feature.
Objective-C
26
star
19

RRFreeShadowsocks

iOS application to grab free configuration from free shadowsocks. And generate configuration line for the Surge iOS app.
Swift
23
star
20

foursquare-kit-ios

Foursquare Kit is a native SDK to include Foursquare API inside mobile apps.
Swift
19
star
21

rocko

🐶 Small, and basic http server, written in full C 🐸
C
19
star
22

EchoBLE

BLE sniffer iOS app using CoreBluetooth.
Swift
17
star
23

RRCustomPageController

Custom PageViewController for iOS
Objective-C
14
star
24

Splime

Splime, is a tool, lets you to split a video into frames.
Swift
11
star
25

AppCoordinator-Segue

AppCoordinator architecture with support of segue.
Swift
11
star
26

BaoMonkey

iOS game.
Objective-C
10
star
27

digital-ocean-messenger-bot

🐬💦 Digital Ocean bot for Facebook Messenger platform :octocat:
JavaScript
10
star
28

giphy-OSX-client

OSX native application to search and visualise animated GIFs from http://giphy.com 🐶
Swift
7
star
29

LoginProvider

LoginProvider abstraction to login with services. RxSwift
Swift
7
star
30

RRDownloadFile

Download file from URL for iOS 7.X
Swift
6
star
31

Naruto-shippuden-iOS

Application iOS, for download and watch Naruto shippuden anime
Objective-C
6
star
32

RROLoadSwizzle

Method swizzling, change the implementation of an existing selector.
Objective-C
6
star
33

RRSoundStatic

Library to manage communication with ultra sound on iOS
Objective-C
6
star
34

CoffeeShopFinder

My very first React Native application iOS / Android
JavaScript
6
star
35

CoreLocationProvider

CoreLocation subscription provider.
Swift
6
star
36

venuesGenerator

Generator of venues, for random data (restaurant, bar, etc), provided by the foursquare API.
JavaScript
6
star
37

RRColorAverageBanner

Banner with color average of a UIImage, inside a UIImageView for display a title or something else.
Objective-C
6
star
38

MNIST-machine-learning

Mydrive hackday machine learning MNIST with data set, iOS client for drawing prediction
Swift
5
star
39

SignalAnalyser

Signal analyser Android application.
Java
5
star
40

LocationKit

Location wrapper around CoreLocation in swift.
Swift
5
star
41

Loop

Handle repetitive loop on iOS easily.
Swift
4
star
42

DigitalOcean

DigitalOcean for python3.4
Python
4
star
43

BlinkiOS

blink iOS app
Swift
4
star
44

SpeedBox

Dropbox, but faster. Written in Node.js
JavaScript
4
star
45

RRGIFAlertPanel

:shipit: Xcode plugin for replace the AlertPanel build succeeded and failed by an animated GIF of your choice !
Objective-C
4
star
46

ObjExporter

Export obj file from a SCNScene in SceneKit
Objective-C
3
star
47

emacs-config

Emacs 24 configuration
Emacs Lisp
3
star
48

RRVideoKit

Librairy, to create a video from UIImage list. With options like repeat frames, and mirroring
Objective-C
3
star
49

WaitBlock

Simple utility for only executing code when you want.
Swift
3
star
50

list

Static library list in C
C
3
star
51

Anime-scrapping

Node.js app to scrap anime download links.
JavaScript
3
star
52

MyMakefile

Makefile for Objective-C, C, C++
2
star
53

ImageDownloader

UIImage downloader from url with cache.
Swift
2
star
54

Fruity

Fruity, custom Xcode template theme.
2
star
55

corewar

Core War personal implementation
C
2
star
56

Color

Swift package to manage AINSI color on terminal
Swift
2
star
57

NotificationObserver

NotificationObserver
Swift
2
star
58

RRLocationManager

Helper Core location with geocoder Swift
Swift
1
star
59

FrogGame

frogGame iOS
Objective-C
1
star
60

MyCurrency

Currency app test
Swift
1
star
61

adok-iOS

iOS application for Adok.
Swift
1
star
62

remirobert.github.io

Personal web site
JavaScript
1
star
63

metasearch-engine

metasearch engine
Python
1
star
64

42sh

unix shell
C
1
star
65

AndroidApp

First android app
Java
1
star
66

TransitionViewController

TransitionViewController is the portage of RRCustomPageController for Swift.
Swift
1
star
67

Gifzat

media creation app
Objective-C
1
star
68

list-ocaml

Recode of the list in Ocaml
OCaml
1
star
69

WechatExample

Wechat SDK
Objective-C
1
star
70

randAlpha

My first iOS application.
Objective-C
1
star
71

go-mobile-twitter-stream

Golang mobile experimentation on iOS. Simple twitter stream client
Swift
1
star
72

EpiDroid

Android app
Java
1
star
73

test-restaurant

Swift
1
star
74

Rentster

iOS app
Objective-C
1
star
75

wegif

iOS app 🐸
Swift
1
star
76

CriminalIntent

:🤖: Android application.
Java
1
star
77

Guess-who

Web application for an educational HACKATON 2014.
JavaScript
1
star