DEV Community

CodingBlocks

The Second Date is Always Easier

The Date deep dive continues as we focus in on C# and JavaScript, while Michael reminisces about the fluorescent crayons, Joe needs a new tip of the week, and Allen confuses time zones.

Let me guess. You’re reading these show notes via your podcast player, right? Well, you can find this episodes full show notes and be a part of the conversation by visiting https://www.codingblocks.net/episode103.

Sponsors

  • Datadog.com/codingblocks – Sign up today for a free 14 day trial and get a free Datadog t-shirt after creating your first dashboard.
  • Clubhouse – The first project management platform for software development that brings everyone on every team together to build better products. Sign up for two free months of Clubhouse by visiting clubhouse.io/codingblocks.
  • Stellares.ai – The AI-powered talent agent that does all the work and screening for you to find your next great opportunity outside of your network. Find the job that’s just right for you.

Survey Says

Anonymous Vote
Sign in with Wordpress
Who is your favorite cloud provider?
  • Amazon AWS baby. The original gangsta of cloud providers.
  • Microsoft Azure. Remember when they called it Windows Azure? Awkward.
  • Google Cloud. Because I also need them to know how I cloud.
  • IBM Cloud. I'm all about the business.
  • Rackspace Cloud. Big enough to be a big deal. Small enough to care.
  • Linode. You gotta love that pricing.
  • Vultr. Bare metal for bare prices.
  • Digital Ocean. A refreshing "droplet".
  • Other. Because how did you not know about my dog's groomer's dad's side cloud business.

News

  • We take a moment to say thank you to everyone that left us a review:
    • iTunes: AtFillmoreEast, Caleb McElroy, LLCFJK, BusterInDallas, Izomlot
    • Stitcher: RustyNipple, Heywood Yapinchme, DuNo06, Anonymous, devisiveNewspaperMethod
  • Allen finally settled on a new laptop, the Gigabyte Aero 15-x9 (Amazon). Video reviews coming soon.

Developer Dates Gone Bad

… in C#

  • In C#, precision is stored to 100 nanoseconds, also known as ticks.
    • A DateTime value is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the Gregorian calendar.
      • This excludes ticks that would be added by leap seconds.
  • The problem with DateTime is similar to that of DATETIME2 in SQL Server, i.e. it can not store any particular timezone offset.
    • However, you can define the DateTime.Kind to be Unspecified or Local or UTC.
  • Matt Johnson breaks down when to use DateTime vs when to use DateTimeOffset in this Stack Overflow answer.
    • And further explains it in his Pluralsight course.

… JavaScript

  • Mozilla’s documentation for Date is awesome.
  • Date.value represents the number of milliseconds since January 1, 1970, 00:00:00 UTC with a range of ± 100,000,000 days relative to this same date.
    • And similar to C#, this excludes leap seconds.
  • JavaScript Date objects can only be instantiated by calling the Date as a constructor (i.e. the word new is in front of it like let myDateObject = new Date().
    • Otherwise, calling it as a regular function, like let myDateString = Date(), will return a string rather than a Date object.
  • The constructor’s monthIndex argument is 0-based, i.e. January = 0 and December = 11.
  • When the constructor is called with multiple arguments and a value is greater than its logical range, i.e. 42 is provided for the day value, the adjacent value will be adjusted.
  • The constructor assumes local time.
    • To specify UTC, use new Date(Date.UTC(…)) with the same arguments.
  • Date.prototype.toISOString() converts a Date to a string following the ISO 8601 extended format.
  • Matt Byers wrote an excellent article on DZone that compares the performance between date-fns and Moment.js.

Resources We Like

Tip of the Week

  • Be sure to check out our YouTube channel!
  • Give Paket a whirl as the dependency manager for your .NET project. (Packet FAQ)
  • Take screenshots of webpages from the command line using either Firefox or Chrome (Bleeping Computer)

Episode source