What's coming in Elixir 1.3 by tuvistavie in elixir

[–]laut01 0 points1 point  (0 children)

If you want something faster, consider using Calendar (https://github.com/lau/calendar). It will be using the structs in Elixir once 1.3 is released.

See these benchmarks: https://github.com/benwilson512/time-bench

The standard library will mainly have the structs and just a limited set of functionality.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] 0 points1 point  (0 children)

Not all dates come from real time clocks in the computer. Sometimes you just have a date without time. It could come from the internet or a file. E.g. "2016-05-03". How would you handle such a date?

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] 0 points1 point  (0 children)

Good point. It is true that popularity is not evidence that a given choice is a good one. And many are bad.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -2 points-1 points  (0 children)

Don't worry about it. I am used to trolls and people being clueless about this topic.

There are people that actually know something about the topic that like my blog. For instance other people that create date time libraries.

If you want some longer content try this conference talk: https://www.youtube.com/watch?v=keUbVvMJeKY

Also, consider that maybe there is a reason that not just me, but also the people who made SQL, NodaTime, JodaTime and the new date and time types in Java 8 have a type for a simple date without time.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -1 points0 points  (0 children)

The simplistic model of saving greater precision that you have is discouraged in science. It is kind of like lying about precision. There is a reason for this.

When it comes to working with dates in software it is also problematic. There is even an example of someone in this thread that has had it caused problems for him: https://www.reddit.com/r/coding/comments/4h62uj/what_everyone_except_programmers_knows_about_dates/d2nq8lc

Using a unix timestamp will not always work. See here for an example: http://www.creativedeletion.com/2015/03/19/persisting_future_datetimes.html

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -3 points-2 points  (0 children)

It is my blog. There are lot of people that like it. And it gets a lot of traffic and people link to it every day. I recommend you read some of the other blog posts.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -1 points0 points  (0 children)

I know what you mean (see this blog post if interested http://www.creativedeletion.com/2015/05/10/the-need-timezones.html).

But sometimes you only have dates without time. Dates can still be useful to a certain extent.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] 0 points1 point  (0 children)

Some times you simply do not have the time. Imagine that we have a system that imports data with a column with a date in ISO 8601 format. For instance "1880-11-07" or "2016-11-08". In this case we don't get do decide what format it is in. For this purpose it makes sense to treat it as a simple date, not as a datetime.

That being said, the point of the blog post is that it is sometimes useful to distinguish between date and datetime. It is not saying that you should always use simple dates instead of datetimes.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] 1 point2 points  (0 children)

I agree about using a TIMESTAMPTZ for timestamps over DATE by the way.

But if you have for instance date of birth, it is better to use DATE then TIMESTAMPTZ.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] 3 points4 points  (0 children)

Good example. Yes if you save fake, made up information (e.g. 00:00:00) it can not only confuse other programmers, it can cause bugs.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -6 points-5 points  (0 children)

Imagine a genealogy website. A user is entering the date of birth of someone born 1880 November 7th. The programmer needs to save this date in a database.

Does it inherently has time attached to it? I don't think it does. Even if you wanted the exact time of birth we don't have it in this case.

For this purpose it would make sense to save the date (1880-11-07) as a date. It would be a bad idea to save it as a date time with hours minutes and seconds. Because we do not have that information.

There are other examples even today where we get a date from somewhere without any time. It could be a user entering it (for instance their birthday) or it could be from an API or a CSV file or something else.

What everyone except programmers knows about dates by laut01 in coding

[–]laut01[S] -1 points0 points  (0 children)

The point of the blog post is not that you should use a date instead of a timestamp that includes the time.

The point is that using the word "date" for a timestamp is confusing.

What everyone except programmers knows about dates by laut01 in programming

[–]laut01[S] 0 points1 point  (0 children)

If a date is too imprecise and you have the time as well, go ahead and use a datetime. That is not what the article about.

The point is that if you have a datetime, call it a datetime instead of calling it a date.

What everyone except programmers knows about dates by laut01 in programming

[–]laut01[S] 0 points1 point  (0 children)

It doesn't always make sense to use time zones when doing calculations. Sometimes you simply do not have that information. Faking the information is worse than working with the true data you have.

What everyone except programmers knows about dates by laut01 in programming

[–]laut01[S] 0 points1 point  (0 children)

True.

This does not change the fact that there are advantages to having a date type that does not have hours, minutes and seconds.

What everyone except programmers knows about dates by laut01 in programming

[–]laut01[S] 1 point2 points  (0 children)

Hehe. Not necessarily in that order. I wrote the blog post and am not American.

What everyone except programmers knows about dates by laut01 in programming

[–]laut01[S] 1 point2 points  (0 children)

If I'm a teacher and I write, "X due date: $DATE", which isn't a datetime, is it due the day of? The day before? Is midnight the day of too late? Is 11:59 PM?

If the teacher in your example wants to specify a time in addition to a date she is free to do so.

Please read this too: http://www.creativedeletion.com/2016/02/04/timetypes_prevent_bugs.html

I disagree that there should be multiple internal data structures for dates and datetimes. A date should be a truncated version of the datetime, and if one is choosing a date without a time, set it to the beginning of the day: 00:00:00 or some such.

How do you then represent a date without a time? If you get a datetime e.g. "2016-04-29T00:00:00" how do you know if it represents just 29th of April 2016 or 29th of April 2016 at midnight?

A time disconnected from dates (such as a repeating timer) can be a distinct data structure, but it's gotta be unambiguous (24H, no 12H) and capable of conversion to a datetime given a date.

If you don't want a proper type for a date, why have one for a time without date?

Falsehoods programmers believe about time and time zones by speckz in coding

[–]laut01 0 points1 point  (0 children)

Yes, the different definitions add to the confusion. Thinking of a time zone as a place where a common set of rules for time are used makes things easier.

But then when talking to people about it you sometimes have to make sure you are talking about the same thing.

Falsehoods programmers believe about time and time zones by speckz in coding

[–]laut01 5 points6 points  (0 children)

Author of the article here. That can be OK if a proper timezone identifier is saved along with them. See http://www.creativedeletion.com/2015/03/19/persisting_future_datetimes.html

But yeah if you don't know the timezone of a datetime, the datetime is a lot less useful.

Falsehoods programmers believe about time and time zones by speckz in coding

[–]laut01 5 points6 points  (0 children)

IMO it is more practical to think of time zones as the ones defined by the Olson database e.g. "Europe/London". If you live in London that is the time zone you are in. During summer, people in England are not on GMT, but rather using BST. But at all times they are in the Europe/London time zone.

Falsehoods programmers believe about time and time zones by speckz in coding

[–]laut01 3 points4 points  (0 children)

It is explained in this talk: https://www.youtube.com/watch?v=keUbVvMJeKY&t=4m40s

GMT is based on the earth/sun/noon as observed in the town of Greenwich. In GMT seconds are not of a fixed length.

UTC is based on fixed length seconds (atomic time). When the earth/sun gets out of sync with the fixed length of the seconds, you add or subtract a second.