Skip to content

Instantly share code, notes, and snippets.

View jwbowles's full-sized avatar

James Bowles jwbowles

View GitHub Profile
jwbowles / excelToSimpleDateFormat
Last active February 17, 2017 10:28
Javascript function to convert Excel date format syntax (used in Google Apps Script spreadsheets) to simpleDateFormat syntax.
function excelToSimpleDateFormat(date, str) {
var excelNonReserved = /([^(m+|d+|y+|am\/pm|a\/p|h+|s+|0+|\[h+\]|\[m+\]|\[s+\])])/gi;
var excelElements = /("[^"]+"|m+|d+|y+|am\/pm|a\/p|h+|s+|0+|\[h+\]|\[m+\]|\[s+\])/gi;
var restrictedChars = /[a-z]+/gi;
var quotes = /"([^"]+)"/;
var minute = /m/g;
var month = /M/g;
var hour = /h/gi;
var seconds = /s/gi;
var ampm = /(a\/p|am\/pm)/gi;