Tips, Thoughts, and Gotchas Working with JavaScript Dates

During an investigation of date related issues in a project I’ve been working on in the day job, I’ve created a detailed write-up on working with dates in JavaScript on my business knowledge base.

You can find it with running code samples at https://kb.vylesk.com/103/tips-thoughts-and-gotchas-working-with-javascript-dates/.

Touch Typing

I was sitting at my computer typing status updates for my team when my wife walked into my office. So I looked at her, smiling, and kept typing to finish the sentence as she was reading what I was typing.

When I finished she looked at me and says: “you’re typing and not even looking.”

It was then I realised for the first time in a long time I have a rather useful skill: I can touch type.

In fact, I can touch type on both a conventional keyboard and, depending on the device/operating system, on a phone.

I may be wrong, but based on much observation of others, I believe that may now be a relatively rare and valuable skill.

But I can tell you one thing for sure: it’s a skill that’s taken many, many, many hours and years of practice to master.

I shit you not! The waste of my development “day job”

I shit you not:
 
Over the last 7 weeks, I’ve spent no less than 140 hours of my “day job” sitting in front of a computer staring at a screen and waiting for the same website to load.
 
Such is the life of a software developer in 2018.
 
I’ve also spent at least 70 hours trying to figure out what the hell other programmers have written.
 
Such is the quality of modern software development.
 
So no less than 75% of my “day job” life is spent being unproductive on a pretty good salary.
 
And that’s why the bloke on that enviable salary, working with so-called “enviable technology” thinks the software development industry is in a terrible state and hates his “day job” at the moment.
 
I have no idea what other software developers see in it all.
 
Thank goodness for the “night job”…

A simple example of an Observable/Subscribe function in TypeScript

I had to work with Observables in JavaScript (RxJS) today and found it, well, bloody hard to find some good examples.

Actually, it’s hard to know what to even search for to find information about Observables (do I search in relation to Angular, Javascript, ECMAScript, TypeScript…?). I found it even harder to decipher most of the highly technical documentation that has been written.

Most examples I found were around making HTTP calls to a server and went no further.

The problem I was solving was to wait for a function that received the results of an HTTP call to finish before then executing other code. That is:

main() — calls –> load() — calls –> httpRequester()

What I need is for load() to return an Observable to main() so I can schedule other code to run only once httpRequester(), and hence load(), where both finished.

After half an hour of looking at examples I figured it out, and for everyone’s benefit, I have created a simple and hopefully easy to understand example on StackBilitz.

Running Example

NOTE: You can pop the editor open in a new window by selecting “Edit On StackBlitz” in the bottom-left of the inserted window.

If you’re using Internet Explorer or there’s just a black window below, here’s the link to the code (and I suggest using a “modern” browser – Chrome and Edge both work): https://stackblitz.com/edit/typescript-vtrstc.