Swifterswift: Questions about DateExtensions

Created on 8 Dec 2017  路  6Comments  路  Source: SwifterSwift/SwifterSwift

  1. My English is not very good, what do the date component "era" and "quarter" mean ? Does "era" mean A.D. / B.C ? Does Jan&Feb&Mar mean first quarter?
  2. If it is like I said, why era always return 1, and quarter always return 0(OC return nil)? A Foundation bug?
    (same problem about this)
    var date = Date() ---> "Dec 8, 2017 at 6:35 PM"
    date.era ---> 1
    date.quarter ---> 0
  3. I found this:
var date = Date() ---> date: "Dec 8, 2017 at 6:35 PM"
date.year = 2020 ---> date: "Jan 1, 2020 at 12:00 AM"
date.hour += 15 ---> date: "Jan 1, 2020 at 3:00 PM"
date.day += 20 ---> date: "Jan 21, 2020 at 12:00 AM"

maybe it is not expected, I just set the year a new value, but month, hour and others all changed, I think it's Apple's problems, but maybe we will never change a date like this way. So I suggest to change every date component computed property to be read-only.

question

All 6 comments

@Asura19 Thank you for bringing this discussion
I'd be more than happy to answer your questions :)

_To confirm_:
Are you using the latest version v4.1 of SwifterSwift? since DateExtensions got a complete re-write in v4.1

@omaralbeik I'm terribly sorry, I got a v4.0.1 馃槄馃槄 馃槄馃槄 馃槄馃槄 馃槄馃槄, just a downloaded version in November, feeling embarrassed.................

@Asura19 No problems at all, please let me know if you have any other question :)

@omaralbeik what does "era" mean?

As Apple's documentation says :

The number of eras.
This value is interpreted in the context of the calendar with which it is used

Which is not clear for me 馃槄, I tried reading the following Wikipedia article as well, and here is what I found:

An era is a span of time defined for the purposes of chronology or historiography, as in the regnal eras in the history of a given monarchy, a calendar era used for a given calendar, or the geological eras defined for the history of Earth.

I've never used era before in any project, what we're doing in SwifterSwift is linking directly to Apple's era implementation.
You might want to ask the question in Apple's Support form to get a clear answer with an example :)

@omaralbeik Thank you very much!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjimenezned picture bjimenezned  路  3Comments

SD10 picture SD10  路  3Comments

omaralbeik picture omaralbeik  路  5Comments

omaralbeik picture omaralbeik  路  5Comments

LucianoPAlmeida picture LucianoPAlmeida  路  4Comments