JavaScript, Date and ISO 8601 part4

Her: How does your perfect date look like?Me: Well the only format I can accept is `YYYY-MM-ddTHH:mm:ssZ` (ISO 8601).Image by Tammy McGaryIf you were reading past articles you know I had fun with dates and JavaScript in the past (Part 1, Part 2 and Part 3).Today I revisited the issue as I was reviewing code at customer site.I ran my test again and…. <drumroll/>All engines in all browser calculate the same date!Chrome 65Firefox 60Opera 52Edge 41Internet Explorer 11BestDaniel

Totally automated Team Foundation 2017 build agent setup

First of all set the default TLS Version for .net to 1.2: With Chocolatey a lot of things are easy to set up:Visual Studio 2017 CommunityWindows Installer XML ToolsetVisual Studio CodeGitVersionNodeJsPython2Remote Server Administration ToolsNow let's modify visual studio and add some components, so that the node-gyp can compile popular packages. We could have used the windows build tools but they default to VS 2015 and the install location of python cannot be adjusted. Visual Studio C++ core features Microsoft.VisualStudio.Component.VC.CoreIdeWindows Universal C RuntimeMicrosoft.VisualStudio.Component.Windows10SDKWindows 10 SDK (10.0.16299.0) for Desktop C++ [x86 and x64]Microsoft.VisualStudio.Component.Windows10SDK.16299.DesktopVC++ 2017 v141 toolset (x86,x64)Microsoft.VisualStudio.Component.VC.Tools.x86.x64We will also utilize code generation using T4:Text Template TransformationMicrosoft.VisualStudio.Component.TextTemplatingThe new MsBuild Project  SDKs requires the installation of .NET Core components of Visual Studio. Otherwise you’ll receive errors like “Error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.”. Additionally we will add the .NET Framework targeting packs to build against several frameworks:.NET Core runtimeMicrosoft.Component.NetFX.Core.RuntimeMicrosoft.Net.Core.Component.SDK.NET Core 2.0 development toolsMicrosoft.NetCore.ComponentGroup.DevelopmentTools.NET Core 2.0 development toolsThe next issues arise: Visual Studio installer is lacking the –wait argument on the command line. So we need to start it as a new process and wait: Next update Visual Studio to its latest version: For Windows Installer XML Toolset we also want the Wix Toolset Visual Studio 2017 Extension to be installed. So we download the latest version from the Visual Studio Marketplace and install it silently: For python we need to add the install location to the path variable:Using NPM we nee to install the following packages globally:Node.js native addon build toolNode SassGulp And finally all together - the final script: HTH

JavaScript, Date and ISO 8601 part3

As there seems some confusion and issues with JavaScript dates (here and here) I wanted to have a look at google Chrome and its ES6 capabilities. So I opened the javascript-harmony setting, enabled it and restarted chrome. I opened up the developer tools and hacked some ES6: Running it on Chrome 55.0.2883.87 m: Meh! The web is broken and nobody cares… So far, so good, so what?

JavaScript, Date and ISO 8601 part2

I had a JavaScript date issue some time ago. Today I looked at the sources of ChakraCore and dug to the point of interest. // Compute the time value timeValue = TvFromDate(year, month, day, timePortionMilliseconds - utcOffsetMilliseconds); if (isLocalTime) { // Compatibility note: // In ES5, it was unspecified how to handle date strings without the trailing time zone offset "Z|(+|-)HH:mm". // In ES5.1, an absent time zone offset defaulted to "Z", which contradicted ISO8601:2004(E). // This was corrected in an ES5.1 errata note. Moreover, the ES6 draft now follows ISO8601. timeValue = GetTvUtc(timeValue, scriptContext); } DateImplementation.cpp line 990   Let's have a look at the ISO8601:2004. B.1.3 Date and time of dayCombinations of calendar date and local time Basic format Extended format Explanation 19850412T101530 1985-04-12T10:15:30 Complete Let's have a look at the EcmaScript 2015 spec at Date Time String Format ( If the time zone offset is absent, the date-time is interpreted as a local time. So as long as I'm running ES5.X Internet Explorer and Edge are wrong according to the EcmaScript spec. Which can be considered wrong according to the ISO spec and is corrected for ES6. <sarcasm>What a wonderful place the web is</sarcasm> I can understand somehow that Microsoft is not fixing this as it is for the old spec. So the next task is to see how the other browsers behave when forced to run ES6

If time is an issue, the lack of reading might be the root cause

Look at the following code:var x = new Date('2016-01-29T14:00:00'); console.log(x.getTime()); Running it in different browsers is surprising1454076000000 // Chrome | FF | Opera 1454072400000 // IE | Edge MDN says: The getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. I repeat according to universal time! ECMA Script Spec says: Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC Pretty accurate. Let's change the code slightly by appending a Z at the end of the string being parsed as date: var x = new Date('2016-01-29T14:00:00Z'); console.log(x.getTime()); Here are the results:1454076000000 // Chrome | FF | Opera 1454076000000 // IE | Edge So it's definitely NOT the getTime() part that lacks. ECMA Script Spec says: The String may be interpreted as a local time, a UTC time, or a time in some other time zone, depending on the contents of the String. The function first attempts to parse the format of the String according to the rules called out in Date Time String Format ( If the String does not conform to that format the function may fall back to any implementation-specific heuristics or implementation-specific date formats. Where the Date Time String Format ( says The value of an absent time zone offset is “Z”. I repeat Z, which is universal time! If only the IE/Edge team was able to read and understand the specs... HTH, Daniel

Updating the .NET target framework for many projects

I do component based development. Meaning I have 30+ repos, builds and each of them has 1-10 projects – The main library project, tests, samples and so on. The news about the support end for the .NET Framework 4, 4.5 and 4.5.1 was the motivation to update ALL of my projects. I know this is not neccessary because… .NET 4.5.2, 4.6 and 4.6.1 are compatible, in-place updates on top of .NET 4, .NET 4.5, and .NET 4.5.1. This means that applications built to target any of these previous .NET 4.x versions will continue running on .NET 4.5.2 without change. No recompiling of apps is necessary. ... but I wanted to update them from version 4 to since a long time now. To do the job I wrote a small powershell script. Beside the path command set-frameworkVersion there is CommitAndPush-GitRepositories which commits and pushes all repositories found underneath the path variable.

Maven Archetypes in IntelliJ

IntelliJ has the ability to use Maven as build and project system. The concept of an archetype is a predefined project or project template.When “File | New project” is used to create a new project and “Maven” is selected the following dialog is displayed:IntelliJ comes with a few archetypes but of course custom ones can be added. On the MVN Repository for example several archetypes for Wildfly are available: XML snipped can be used as copy-paste-source for IntelliJ’s “Add archetype dialog”:After clicking the “OK” button the newly added archetypes are available as a source for the project creation. The custom archetypes are stored in the file “C:\{username}\Daniel\.IntelliJIdea{version}\system\Maven\Indices\UserArchetypes.xml” on Windows and “~/.IntelliJIdea{version}/system/Maven/Indices/UserArchetypes.xml” on Linux. Next define group and artifact identifier as well as version for the new project:Select the Maven version:And the project location:The result is a runnable quick start for working with the Wildfly application server.

Code Snippets in IntelliJ

Code snippets can be helpful. Otherwise the can lead to code duplicates – so use them with wisely.In JetBrains IntelliJ the code snipptes are called Live Templates. They are stored in files saved in C:\Users\{UserName}\.IntelliJIdea{Version}\config\templates on Windows and ~/.IntelliJIdea{Version}/config/templates on Linux. To create a live template open IntelliJ and open the Settings from the File menu:In the Settings dialog you can use the search text box to quickly access the Live Templates section:Now just select the Language and use the green plus button on the upper right to add a new one (like the iife that I just added here).There is a special placeholders that can be used aside from variables:$SELECTION$The Edit variables button switches to enabled state as soon as you user a variable name in the code.

Enable or disable FxCop Code Analysis solution wide in Visual Studio Package Manager Console

I really like FxCop. But in a debugging session it can be useful to save time by temporarily disabling the code analysis. Sadly there is no *global switch* to turn it off and on again. So here is my approach: Create a new text file in the directory "C:\Users\{your user}\Documents\WindowsPowerShell" named "NuGet_profile.ps1" and add the following code: Restart Visual Studio. Click the menu "View" | "Other Windows" | "Package Manager Console". Now you can execute the following commands: > Enable-CodeAnalysis > Disable-CodeAnalysis