novalagung / Nvdate
Licence: mit
đ
Swift4 Date extension library
Stars: â 176
Projects that are alternatives of or similar to Nvdate
Tosmbclient
An Objective-C binding around the libDSM SMB client library.
Stars: â 162 (-7.95%)
Mutual labels: cocoapods
Bluetoothkit
Easily communicate between iOS/OSX devices using BLE
Stars: â 2,027 (+1051.7%)
Mutual labels: cocoapods
Wkcookiewebview
WKWebView with cookie sharing support
Stars: â 171 (-2.84%)
Mutual labels: cocoapods
Vbpiledview
Simple and beautiful stacked UIView to use as a replacement for an UITableView, UIImageView or as a menu
Stars: â 164 (-6.82%)
Mutual labels: cocoapods
Opalimagepicker
A multiple image picker for iOS, written in Swift
Stars: â 165 (-6.25%)
Mutual labels: cocoapods
Multipeer
đąđ˛ A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: â 170 (-3.41%)
Mutual labels: cocoapods
Campcotcollectionview
Collapse and expand UICollectionView sections with one method call.
Stars: â 161 (-8.52%)
Mutual labels: cocoapods
Countrypicker
A simple, customizable Country picker for picking country or dialing code. đŽđŗ đ¯đĩ đ°đˇ đŠđĒ đ¨đŗ đēđ¸ đĢđˇ đĒđ¸ đŽđš đˇđē đŦđ§
Stars: â 174 (-1.14%)
Mutual labels: cocoapods
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: â 12,584 (+7050%)
Mutual labels: cocoapods
Forecastio
A Swift library for the Forecast.io Dark Sky API
Stars: â 164 (-6.82%)
Mutual labels: cocoapods
Thememanager
ThemeManager is a lightweight library for application to switching themes. support more attributes and theme extensions. more easy and convenient to use.
Stars: â 165 (-6.25%)
Mutual labels: cocoapods
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: â 172 (-2.27%)
Mutual labels: cocoapods
Tiercel
įŽåæį¨ãåčŊ丰å¯įįē¯ Swift ä¸čŊŊæĄæļ
Stars: â 2,241 (+1173.3%)
Mutual labels: cocoapods
Toactionsheet
A custom-designed reimplementation of the UIActionSheet control for iOS
Stars: â 175 (-0.57%)
Mutual labels: cocoapods
Tosegmentedcontrol
A segmented control in the style of iOS 13 compatible with previous versions of iOS.
Stars: â 174 (-1.14%)
Mutual labels: cocoapods
Svprogresshud
A clean and lightweight progress HUD for your iOS and tvOS app.
Stars: â 12,339 (+6910.8%)
Mutual labels: cocoapods
Introduction
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.
Features
- Has lot of API function to make date and time manipulation easier and fun
- Has user friendly naming convention
- NVDate functions are chainable
- Very easy to use
- Open Source!
Installation
Using Cocoa Pods
Swift4
Add these into your Podfile
:
pod 'NVDate', '2.0.1'
Then import NVdate
into your swift file.
import NVDate
Objective-C
Add these into your Podfile
:
pod 'NVDate', '1.0.0'
Then import NVdate.h
into your .h or .m file.
#import "NVDate.h"
Simple Example
Today date as string
let date = NVDate()
print(date.asString())
// ==> Wednesday, February 5, 2014, 4:56:35 PM Western Indonesia Time
Date 2018/05/25 as string
let date = NVDate(fromString: "2018/05/25", withFormat: "yyyy/MM/dd")
print(date.asString())
// ==> Friday, May 25, 2018, 00:00:00 AM Western Indonesia Time
Last day of next 2 months
let date = NVDate()
.nextMonths(diff: 2)
.lastDayOfMonth()
print(date.asString(withFormat: "dd-MM-yyyy"))
// ==> 30-04-2014
Second week of 2 months ago
let date = NVDate()
.previousMonths(diff: 2)
.firstDayOfMonth()
.nextWeek()
date.dateFormat(setFormat: "yyyy-MM-dd HH:mm:ss")
print(date.asString())
// ==> 2013-12-08 17:03:36
Detect if 2018/05/25 is friday
let todayIsFriday = NVDate(year: 2018, month: 5, day: 25)
.previousDay()
.isTodayName(.friday)
print(todayIsFriday)
// ==> false
Dot syntax
let someday = NVDate()
.previousDay()
.previousWeek()
.nextDay()
.asString()
print(someday)
// ==> 2013-12-08 17:03:36
API Documentation
Initialization
Initialization | Description |
---|---|
NVDate() |
Today date is used as date value |
NVDate(fromString:withFormat:) |
Use specified date string as date value. Format of specified date string has to be explicitly defined. |
NVDate(year:month:day:) |
Construct new date using year, month, and day |
NVDate(year:month:day:hour:minute:second:) |
Construct new date using year, month, day, hour, minute, second |
NVDate(fromDate:) |
use specified date as value |
Methods
Method | Description |
---|---|
date() |
return the date object |
asString() |
return string formatted of date object |
asString(withFormat:) |
return formatted string value of date object. the format has to be defined explicitly |
setTimeAsZero() |
set hour, minute, and second as 0 |
dateFormat() |
return the current date format. the format is used on asString()
|
dateFormat(setFormat:) |
change current date format. the format is used on asString()
|
dateStyle() |
return the date style of current formatter |
dateStyle(setStyle:) |
change date style of current formatter |
timeStyle() |
return the time style of current formatter |
timeStyle(setStyle:) |
change time style of current formatter |
timeZone() |
return current timezone value |
timeZone(setTimeZone:) |
change the timezone value |
nextDays(days:) |
move to next x days |
nextDay() |
move to next day |
tomorrow() |
alias of nextDay()
|
previousDays(days:) |
move to previous x days |
previousDay() |
move to previous day |
yesterday() |
alias of previousDay()
|
nextWeek() |
move to next week |
nextWeeks(diff:) |
move to next x weeks |
previousWeek() |
move to previous week |
previousWeeks(diff:) |
move to previous x weeks |
nextMonth() |
move to next month |
nextMonths(diff:) |
move to next x months |
previousMonth() |
move to previous month |
previousMonths(diff:) |
move to previous x months |
nextYear() |
move to next year |
nextYears(diff:) |
move to next x years |
previousYear() |
move to previous year |
previousYears(diff:) |
move to previous x years |
firstDayOfMonth() |
move to first day of current month |
lastDayOfMonth() |
move to last day of current month |
firstMonthOfYear() |
move to first month of current year |
lastMonthOfYear() |
move to last month of current year |
nearestPreviousDay(_:) |
move to x previous day that name equal to NVDate.DayName
|
nearestNextDay(_:) |
move to x next day that name equal to NVDate.DayName
|
thisDayName() |
get today day name, in type NVDate.DayName
|
todayName() |
alias of thisDayName()
|
isThisDayName(_:) |
return true if specified day name is equal with day on the object |
isTodayName(_:) |
alias of isThisDayName(_:)
|
thisMonthName() |
get this month name, in type NVDate.MonthName
|
isThisMonthName(_:) |
return true if specified month name is equal with month on the object |
year() |
return year value |
year(setYear:) |
change year value |
month() |
return month value |
month(setMonth:) |
change month value |
weekOfYear() |
return week of year value |
weekOfMonth() |
return week of month value |
day() |
return day value |
day(setDay:) |
change day value |
hour() |
return hour value |
hour(setHour:) |
change hour value |
minute() |
return minute value |
minute(setMinute:) |
change minute value |
second() |
return second value |
second(setSecond:) |
change second value |
Contribution
Feel free to contribute by doing fork
-> pull request
License
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].