Codey Bits

A coworker of mine had an interesting problem regarding cross-browser javascript dates.

Does this look fine to you?

newDate('2016-08-29T14:42:07.56')

It looks fine to me. It turns our it's not fine. In order for this code to return you an expected datetime across browsers (in our case Chrome and IE), we should specify either a timezone or a specific offset. Since we didn't particularly care to add a specific offset, we used

newDate('2016-08-29T14:42:07.56Z')

Yep, we just slapped a "Z" on there. Apparently, "Z" is a zero-time UTC offset (-00:00).

This happens because Chrome assumes an unspecified date to be a UTC time with a zero-offset, while IE assumes the timezone should be the same timezone of the client machine (in our case, EST, -05:00).

If you wanted to specify your particular locale's offset, you could construct the date this way

newDate('2016-08-29T14:42:07.56Z-05:00')

Thanks to Moshe Karmel for the advice!

For reasons like this, I tend to use momentjs for basically everything having to do with dates.

I've recently had a situation come up at work where I need to protect our ASP.NET Web API 2 deployment with Windows Authentication. We run our web client through Chrome and IE and we needed the NTLM negotiation to be handled gracefully. There are a few things that we had to put in place to get this to go. Here they are in list form. The code for both the problem and the solution is here on my github.

Recently I had to scrape together a quick demo of an Angular app that talks to a Web API 2 solution using the jsonp() shortcut method of the $http service. As it turns out, Web API 2 does not ship with JSONP support out of the box.

A friend of mine asked me to do a tutorial on SQL, so here we go! This article will begin to introduce relational database concepts and will end with a few examples of how to retrieve data from a database using the select keyword. I'll stick to keeping this intro extremely basic - SQL heads please chime in with anything that might help someone just starting off in the world of databases. We will be approaching this topic from the perspective of an application developer - not a Database Administrator. Here's a TLDR for those who prefer to start at the end and work your way back to the beginning.

This is a small intro to using one of the fun new(ish) HTML5 APIs - Web Storage. I'll be focusing on the localStorage API, but there are also sessionStorage and indexedDB that you might consider using in your application. Here's the fiddle for what I'm going to be talking about.

Recently, I've been getting deep into JavaScript. It was my first programming language many years ago. Since then, some extremely interesting patterns and practices have emerged. As a primarily C# developer, I looked into the Revealing Module pattern as a way to ease myself back into JS coding in an OOP-friendly way.

At work, I'm currently building a multi-module JS app with RESTful backend, using Google's AngularJS library for only one of the modules. I was worried about how it would act when integrated with an app that also makes use of jQuery and Bootstrap. As it turns out, it's totally fine! This post is an overview of my approach to modularizing Angular functionality.

If you're the kind of person who likes to dig into the code before hearing the explanation, here's a fiddle that contains everything I'll be talking about.