Comments (14)
@Prince2k3 Thanks! Now, this library uses NSCalendar
's timezone, which the user specified at Settings. When do you want to set/get timezone?
from timepiece.
So I have a scenario where I would need to check the date at a certain timezone because a server only acts within it. Like for instance checking to see if a transaction is valid before a certain time in CST.
from timepiece.
Oh, I see. For example, is it favorable for you to set/get timezone like below?
let cst = NSTimeZone(abbreviation: "CST")
let lastWeekInCST = 1.week.ago.in(timezone: cst)
lastWeekInCST.timezone
//=> cst
from timepiece.
Yes ...that would be very nice setup!
from timepiece.
OK! I will try to implement above feature!
from timepiece.
Sweet! Thanks!
from timepiece.
@Prince2k3, I have implemented features to set/get the time zone. Please check the playground at 24a1173! If there is no problem, I will merge this and release as the next version.
from timepiece.
I noticed that the calculation and comparison of dates with different time zones are not implemented. After they are implemented, I will release this feature.
from timepiece.
Hey tested the the timezone feature and it works. Yeah if there is any way to sort the length of this code even more. Then I'm all for it!
extension NSDate {
func canCancel() -> Bool {
var currentDate = NSDate().change(timeZone: NSTimeZone(abbreviation: "CST")!)
if currentDate.day == day && (currentDate.hour < 13 || (currentDate.hour > 13 && hour > 13)) {
return true
} else if (currentDate.timeIntervalSinceDate(self) < 86400) && (hour >= 13) && currentDate.hour < 13 {
return true
}
return false
}
}
from timepiece.
What did you have in mind for calculation and comparison? So far I seem to do that just fine if I make sure that the timezones are the same.
from timepiece.
For example, I think now == now.change(timeZone: cst)
should be true
. But, actually the result is false
in current implementation. When we calculate or compare dates with different time zones, we should change the time zone of either date into one of another date.
from timepiece.
I added tests for above cases, which are all passed without any additional implementations. It looks fine. @Prince2k3, can I merge this branch?
from timepiece.
Yes! ... I think it looks good as well!
from timepiece.
@Prince2k3 Thanks!
from timepiece.
Related Issues (20)
- problems installing with CocoaPods
- Swift Package Manager support, please make this happen
- A new release version?
- SPM 1.3.1 version doesn't work HOT 1
- syntactic sugar for week days HOT 3
- Missing interval ? HOT 2
- inFormat is returning wrong weekday HOT 5
- Weekend HOT 5
- How to modify a date. HOT 4
- How to modify the time zone HOT 4
- changing timezone HOT 2
- Shortcut for timeIntervalSince(_:) HOT 3
- time ago support HOT 3
- Wrong time retrieved
- How to find number of days in a particular year? HOT 1
- endOfDay handles date differently for iOS 10 as it does for iOS 11
- Change the default calendar HOT 4
- Can you add more date math examples to readme? HOT 2
- Swift 4.2 HOT 1
- swift 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timepiece.