From 23951d6c0e37aee62fc14ef5a37dbed6b0340cdb Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 1 Jul 2019 13:06:46 -0300 Subject: [PATCH] New Chapter: Timezones --- content/books/things-i-learnt/_index.md | 1 + .../languages-are-more/index.md | 2 +- .../things-i-learnt/resist-easy/index.md | 2 +- .../things-i-learnt/use-timezones/index.md | 35 +++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 content/books/things-i-learnt/use-timezones/index.md diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index 682e859..8e15213 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -39,6 +39,7 @@ template = "section-contentless.html" * [If Your Data Has a Schema, Use a Structure](use-structures) * [Don't Mess With Things Outside Your Project](outside-project) * [Resist The Temptation Of Easy](resist-easy) + * [Always Use Timezones With Your Dates](use-timezones) * Community/Teams * [A Language Is Much More Than A Language](languages-are-more) * [Understand And Stay Away From Cargo Cult](cargo-cult) diff --git a/content/books/things-i-learnt/languages-are-more/index.md b/content/books/things-i-learnt/languages-are-more/index.md index 0943de6..f53fa5f 100644 --- a/content/books/things-i-learnt/languages-are-more/index.md +++ b/content/books/things-i-learnt/languages-are-more/index.md @@ -39,4 +39,4 @@ surface of what the whole of a language encapsulates and if you ignore the other elements in it, you may find yourself with a cute language in a community that is always fighting and never going forward. -{{ chapters(prev_chapter_link="/books/things-i-learnt/resist-easy", prev_chapter_title="Resist The Temptation Of Easy", next_chapter_link="/books/things-i-learnt/outside-project", next_chapter_title="Don't Mess With Things Outside Your Project") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/outside-project", next_chapter_title="Don't Mess With Things Outside Your Project") }} diff --git a/content/books/things-i-learnt/resist-easy/index.md b/content/books/things-i-learnt/resist-easy/index.md index f033a72..dc9212d 100644 --- a/content/books/things-i-learnt/resist-easy/index.md +++ b/content/books/things-i-learnt/resist-easy/index.md @@ -28,4 +28,4 @@ These days, IDEs can autocomplete almost everything, from function names to even how to name your variables. But using the autocomplete is not always a good solution. Finding better names is. -{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/languages-are-more", next_chapter_title="A Language Is Much More Than A Language") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/use-timezones", next_chapter_title="Always Use Timezones With Your Dates") }} diff --git a/content/books/things-i-learnt/use-timezones/index.md b/content/books/things-i-learnt/use-timezones/index.md new file mode 100644 index 0000000..976fc33 --- /dev/null +++ b/content/books/things-i-learnt/use-timezones/index.md @@ -0,0 +1,35 @@ ++++ +title = "Things I Learnt The Hard Way - Always Use Timezones With Your Dates" +date = 2019-07-01 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "dates", "timezones"] ++++ + +No matter if the date you're receiving is in your local timezone and you'll +display it in your timezone. Sooner or later, the fact that you ignored there +was a timezone behind that date will hurt you. + + + +(Note: Most of this post when I say "date" you can think of "date and time", +although the date should also be timezone aware.) + +At some point of my professional life, ignoring timezones was easy: You just +pick the date, throw in the database, then read it back and everybody was +happy. + +But things are not like this anymore. People will access your site from far +away locations, the source of the date may not be in the same timezone of your +system, your system may be running in a completely different timezone of your +dev machine (it's pretty common to run things in our machines in the local +timezone but the production system will run in UTC), the display may be a +complete different timezone than your production and dev machine and so on. + +So always carry the timezone with the data. Find modules/classes that support +dates with timezones (a.k.a. make things _timezone aware_), capture the +timezone as soon as possible and carry it around in all operations. +Modules/classes that don't support timezones for dates/times should, as soon +as possible, removed from the system. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/languages-are-more", next_chapter_title="A Language Is Much More Than A Language") }}