Skip to content

Commit

Permalink
add support for date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mderazon committed Dec 4, 2016
1 parent 6c46d74 commit dc88450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion example.html
Expand Up @@ -16,6 +16,7 @@
misc: [
['i am an arrray'],
{i:{am:{an:'object'}}},
new Date(),
'string',
42,
true,
Expand All @@ -25,4 +26,4 @@
});
</script>
</body>
</html>
</html>
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -27,6 +27,7 @@ function type (doc) {
if (doc === null) return 'null'
if (Array.isArray(doc)) return 'array'
if (typeof doc === 'string' && /^https?:/.test(doc)) return 'link'
if (typeof doc === 'object' && typeof doc.toISOString === 'function') return 'date'

return typeof doc
}
Expand Down Expand Up @@ -63,6 +64,9 @@ module.exports = function (doc, styleFile) {
case 'number':
return '<span ' + style('json-markup-number') + '>' + obj + '</span>'

case 'date':
return '<span class="json-markup-string">"' + escape(obj.toISOString()) + '"</span>'

case 'null':
return '<span ' + style('json-markup-null') + '>null</span>'

Expand Down

0 comments on commit dc88450

Please sign in to comment.