• Stars
    star
    2,631
  • Rank 17,401 (Top 0.4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 5 years ago

Reviews

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

Repository Details

Intuitive date handling in Swift

Timepiece CocoaPods Compatible Build Status

Intuitive date handling in Swift

Features

  • 💡 Intuitive: Timepiece provides a set of helpers to make date handling easier.
  • 🕘 Correct: Using Foundation API correctly, Timepiece helps to calculate dates correctly without deep understanding.
  • 📦 Small: Timepiece has only 4 file. You can read the inside of this easily.

Requirements

  • Swift 3.0+
  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+

Usage

Initialization

Date(era: 235, year: 26, month: 8, day: 14, hour: 20, minute: 25, second: 43, nanosecond: 0, on: Calendar(identifier: .japanese))
Date(year: 2014, month: 8, day: 14, hour: 20, minute: 25, second: 43, nanosecond: 0)
Date(year: 2014, month: 8, day: 14, hour: 20, minute: 25, second: 43)
Date(year: 2014, month: 8, day: 14)

Date.today()
Date.yesterday()
Date.tomorrow()

Calculation

now + 1.year
now - 2.months
now + (3.weeks - 4.days + 5.hours)

1.year.later
1.year.ago

Change

now.changed(year: 2014)
now.changed(weekday: 1)
now.truncated([.minute, .second, .nanosecond])
now.truncated(from: .day)

Formating

now.stringIn(dateStyle: .long, timeStyle: .medium)
now.dateString(in: .medium)
now.timeString(in: .short)

3.days.string(in: .full)

Parsing

"2014/8/14".date(inFormat: "yyyy/MM/dd")
"2014-08-14T20:25:43+0900".dateInISO8601Format()

Installation

CocoaPods

# Podfile
pod "Timepiece"

Carthage

# Cartfile
github "naoty/Timepiece"

Contribution

  1. Fork
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Timepiece is available under the MIT license. See the LICENSE file for more info.

Author

naoty

More Repositories

1

flock

Object graph in Swift
Swift
35
star
2

brancher

A rubygem switching databases by Git branch
Ruby
35
star
3

todo

A TODO manager just for me
Ruby
32
star
4

graphdown

Markdown extension for embedding graphs.
Ruby
28
star
5

NTYSmartTextView

NSTextView with smart features
Objective-C
27
star
6

clr

A command to create colorlists files
Swift
27
star
7

picon

Generator of identicons for iOS apps
Ruby
22
star
8

cui-aboutme

The hacker's profile downloader
Ruby
20
star
9

qiita-swift

Qiita API v2 client for Swift
Swift
17
star
10

AnyQuery

Soft-typed query for anything
Swift
17
star
11

NTYCSVTable

CSV parser for Objective-C inspired by CSV::Table class of Ruby.
Objective-C
16
star
12

table

A command to print ASCII table from stdin
Rust
14
star
13

tinydot

Tiny language alternative to DOT.
Ruby
14
star
14

med

A hackable markdown editor for OS X
Objective-C
11
star
15

glide

A framework for easily making slides
Ruby
11
star
16

Stream

Swift library to control streams on Functional Reactive Programming model
Swift
10
star
17

params_inquirer

ParamsInquirer gives you a prettier way to inquire params value.
Ruby
10
star
18

NTYPopulator

A seed data populator for Core Data.
Objective-C
9
star
19

Playground

🐤 Experimental projects 🐤
Swift
8
star
20

NTYAirData

A RESTful API server for Core Data
Objective-C
8
star
21

haas.js

HTML as a slide
CoffeeScript
6
star
22

hot

List files in order of the commited count
Go
5
star
23

redcarpet_filename_extension

Redcarpet custom renderer for code blocks with filename.
Ruby
5
star
24

LowpassStreamSample

Low-pass filter implementation using Stream
Swift
3
star
25

ext

A convention for command extensions
Go
3
star
26

mirror_bot

Twitter bot mirroring you
Ruby
3
star
27

cocoapods-src

CocoaPods plugin for automatic `git clone`
Ruby
3
star
28

esa-history

esaの閲覧履歴を管理するChrome拡張
Vue
3
star
29

fish-my_peco_functions

My peco functions for fish
Shell
3
star
30

pingpong

WebSocket server written by Ruby
Ruby
3
star
31

batch_rollback

A rubygem to enable db:rollback to rollback all versions previously migrated
Ruby
2
star
32

sweep

Delete expired items in Pocket
Go
2
star
33

reversibility_checker

A rubygem to check the reversibility of migration files
Ruby
2
star
34

MDViewer

Markdown viewer for iPad
Objective-C
2
star
35

vim-folcom

Vim plugin to fold comments
Vim Script
2
star
36

raspi-chef-repo

My chef repository
Ruby
2
star
37

mdserve

A web server providing RESTful API for markdown contents
Go
2
star
38

NTChartView

An easily charting library for iOS
Objective-C
2
star
39

homebrew-misc

My misc formulae for the Homebrew package manager
Ruby
2
star
40

NTLevelMeterView

Level meter for iOS
Objective-C
2
star
41

TQKey-Swift

TQKey app written by Swift
Swift
2
star
42

qiita_recommendation

Qiita Recommendation tool
Ruby
2
star
43

ruboty-timecard

A handler for Ruboty to punch a timecard.
Ruby
2
star
44

NTYChangeLog

A rubygem to parse CHANGELOGs in my style
Ruby
2
star
45

BetterFormApp

Sample application
Swift
2
star
46

icon

My icon generator
Go
1
star
47

makura-web

plot a chart with pressure data sent from arduino
JavaScript
1
star
48

git-contrib

Show contributors for speficied files
Go
1
star
49

dotfiles

Vim Script
1
star
50

MyQiita

Experimental iOS application
Swift
1
star
51

stl_viewer

STL viewer application on Heroku
JavaScript
1
star
52

cputil-vimp

A vimperator plugin for copying the title of a current page
JavaScript
1
star
53

nowis

Answer when now is
Go
1
star
54

gem-uninstall-all

gem uninstall all
Go
1
star
55

NTYFactory

Data bootstrapping factory for Core Data.
Objective-C
1
star
56

Nakameguro

Limechat theme
1
star
57

rapiro_brain

The brain of RAPIRO
Ruby
1
star
58

task

A task manager based on TUI just for me
Go
1
star
59

lgtm-vimp

LGTM Vimperator plugin
JavaScript
1
star
60

nippo

日報作成スクリプト
Shell
1
star
61

stlgen

STL generator
Ruby
1
star
62

fzf-functions

My shell functions for fzf
Shell
1
star
63

homepage

My homepage
TypeScript
1
star
64

FaceDetectSample

A sample application to detect faces with CIDetector
Objective-C
1
star
65

ruboty-google_spreadsheet

Store Ruboty's memory in Google Spreadsheet.
Ruby
1
star
66

TQKey

卓球ハウス用在宅管理アプリ
Objective-C
1
star
67

svgen

SVG generator
Ruby
1
star
68

tqkey-api

卓球ハウス用在宅管理アプリAPI
Ruby
1
star
69

slack-thread-webhook

Slack webhook to post threaded messages
Go
1
star
70

require

A dart package to support design by contract in declarative style
Dart
1
star
71

kifu-player

TypeScript
1
star