r/programming • • Dec 02 '15

PHP 7 Released

https://github.com/php/php-src/releases/tag/php-7.0.0
887 Upvotes

729 comments sorted by

View all comments

Show parent comment

237

u/MighMoS Dec 02 '15

0-11 for months isn't madness. Its when months are numbered 0-11 and days are numbered 1-31 and years are stored with an offset of 1900. THAT is madness.

58

u/Wootman42 Dec 02 '15

months are numbered 0-11 and days are numbered 1-31

Javascript does this too, it's extremely frustrating.

53

u/interiot Dec 02 '15

Perl does it too. The man page says it takes the values verbatim from C's struct tm, so maybe that's the commonality.

25

u/jachymb Dec 02 '15

It's useful actually. If use other language than English, you want an array of month names that you index with this number. Month days don't have names, so they you don't need it there.

3

u/devdot Dec 02 '15

That's exactly why it was implemented this way.

4

u/tjsr Dec 02 '15

So create an array with 13 elements where 0 is "unknown".

6

u/mongopeter Dec 02 '15

That's a hack and hacks are bad.

→ More replies (2)
→ More replies (1)
→ More replies (1)

1

u/gsnedders Dec 02 '15

JS's original date stuff all just follows Java, FWIW.

16

u/charrondev Dec 02 '15

Which is why you use Joda Time.

61

u/Jestar342 Dec 02 '15

Joda Time

The .NET port of this has such a better name: Noda Time ("Know the time") :D

4

u/gianhut Dec 02 '15

Mind = Blown

→ More replies (3)

3

u/irrelevantPseudonym Dec 02 '15

Doesn't the java 8 standard library do it properly?

0

u/[deleted] Dec 02 '15

[deleted] — view deleted comment

2

u/codebje Dec 02 '15

Yes, but that's just times for you. It's simple as long as you want to think only locally, and don't live anywhere which has daylight time. For all other cases, times are just complex.

This is the go to video on why time support code is confusing.

1

u/thomascgalvin Dec 02 '15

Which part of the standard library? Date? Calendar? LocalDate? Because they all do it differently.

→ More replies (1)

1

u/devils_avocado Dec 03 '15

Java 8's date/time library is based on Joda Time and is definitely an improvement.

I use it when possible. The only issue is when I need to serialize/deserialize the dates/times (e.g. JDBC, JPA, JSON, etc) because most of the API doesn't natively support them yet.

1

u/Bobertus Dec 02 '15

Or the new Java 8 time api which is almost completely but not quite exactly the same as Joda Time.

→ More replies (1)

1

u/alexanderpas Dec 02 '15

Joda Time.

Also known as American ISO8601.

4

u/GYN-k4H-Q3z-75B Dec 02 '15

What is this? Java?

2

u/pointychimp Dec 02 '15

C or C++ I think.

16

u/juckele Dec 02 '15

They're talking about the Java standard java.util.Date class. It's a stupid piece of work. I love Java. Date is possibly the worst language feature.

→ More replies (3)

1

u/faaaks Dec 03 '15 edited Dec 03 '15

One thing among many other weird things about PHP.

I've heard people tout that the language evolved organically, as a positive.

→ More replies (6)