Giter Site home page Giter Site logo

Comments (17)

Huanqiang avatar Huanqiang commented on June 2, 2024

我怀疑是不是时区的问题呢?但是我不知道怎么改,还请麻烦您看下。

from timepiece.

naoty avatar naoty commented on June 2, 2024

I don't understand Chinese. Would you tell me your issue in English?

from timepiece.

Huanqiang avatar Huanqiang commented on June 2, 2024

@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:
1ea4142f-6161-410b-bf68-9cdee780dcb4
bebb3a14-359b-4bee-89b5-8e0d6040117e

from timepiece.

Huanqiang avatar Huanqiang commented on June 2, 2024

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.

Huanqiang avatar Huanqiang commented on June 2, 2024

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.

naoty avatar naoty commented on June 2, 2024

There is something wrong... I'll try to investigate this problem! Thank you for reporting.

from timepiece.

Huanqiang avatar Huanqiang commented on June 2, 2024

Thank you for your efforts, look forward to your results, thank you

from timepiece.

naoty avatar naoty commented on June 2, 2024

@861645007 Sorry for late reply! I found that the result of print(date) looks strange, but actually todayEnd.hour returns 0. Screenshots are here.

2016-02-13 20 55 34
2016-02-13 20 55 41

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.

naoty avatar naoty commented on June 2, 2024

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.

Huanqiang avatar Huanqiang commented on June 2, 2024

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)

aa2e84e1-6cae-42ae-93a1-f65490a52e21

from timepiece.

Huanqiang avatar Huanqiang commented on June 2, 2024

I don't know if my guess is right, please look at it.

from timepiece.

naoty avatar naoty commented on June 2, 2024

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.

Huanqiang avatar Huanqiang commented on June 2, 2024

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.

Huanqiang avatar Huanqiang commented on June 2, 2024
func tolocalTime() -> NSDate {
        let tz = NSTimeZone.localTimeZone()
        let seconds: NSInteger = tz.secondsFromGMTForDate(self)
        return NSDate(timeInterval: Double(seconds), sinceDate: self)
    }

from timepiece.

naoty avatar naoty commented on June 2, 2024

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

Huanqiang avatar Huanqiang commented on June 2, 2024

-change(timeZone:) this method can't play a part in this problem

from timepiece.

naoty avatar naoty commented on June 2, 2024

@861645007 Could you send a pull request includes tests regenerating your problem and codes solving them?

from timepiece.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.