Comments (17)
我怀疑是不是时区的问题呢?但是我不知道怎么改,还请麻烦您看下。
from timepiece.
I don't understand Chinese. Would you tell me your issue in English?
from timepiece.
@naoty
Sorry: my English is not good.
I am trying to set the start time of today (for example: 2016-01-29 00:00:00), but the result is not right. Code as follows:
from timepiece.
I suspect that this problem is related to the time zone? But I do not know how to change, but also please trouble you.
from timepiece.
Hi,sir:
I'm so sorry to bother you, but I really don't know how to solve this problem. Please, help me.
from timepiece.
There is something wrong... I'll try to investigate this problem! Thank you for reporting.
from timepiece.
Thank you for your efforts, look forward to your results, thank you
from timepiece.
@861645007 Sorry for late reply! I found that the result of print(date)
looks strange, but actually todayEnd.hour
returns 0
. Screenshots are here.
This problem is caused by the wrong implementation of CustomStringConvertible
for extended NSDate
. This protocol defines a customized text format returned by print
and so on.
I will try to fix the implementation! Thank you for reporting!
from timepiece.
It seems that the override of description
, which is defined at CustomStringConvertible
, is not allowed. I don't know how to solve this problem...
from timepiece.
I think that the problem is UTC and GMT。we can get UTC of time from NSDate()
, but current time which we print is GMT, It is a difference of 8 hours(when i use beijing time)
from timepiece.
I don't know if my guess is right, please look at it.
from timepiece.
Yes, your guess is right. The result of print
ignores the timezone because the implementation of CustomStringConvertible
for extended NSDate
doesn't consider the timezone. If possible, I want to override describe
property to consider the timezone. But, it seems that the override is not allowed...
from timepiece.
hi:
I think you can use this method to change the time. Although this is not a good way, it can be a temporary solution to this problem. i hope you can find a better method.
func tolocalTime() -> NSDate { let tz = NSTimeZone.localTimeZone() let seconds: NSInteger = tz.secondsFromGMTForDate(self) return NSDate(timeInterval: Double(seconds), sinceDate: self) }
from timepiece.
func tolocalTime() -> NSDate {
let tz = NSTimeZone.localTimeZone()
let seconds: NSInteger = tz.secondsFromGMTForDate(self)
return NSDate(timeInterval: Double(seconds), sinceDate: self)
}
from timepiece.
@861645007 If you want to change the timezone, you should use -change(timeZone:)
at here.
BTW, would you change the title of this issue in English?
from timepiece.
-change(timeZone:)
this method can't play a part in this problem
from timepiece.
@861645007 Could you send a pull request includes tests regenerating your problem and codes solving them?
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.