Skip to content

Commit

Permalink
Merge pull request #41 from 3cp/fix-time-format
Browse files Browse the repository at this point in the history
Fix time format
  • Loading branch information
fkleuver authored Feb 1, 2021
2 parents 4f9f8d9 + 570a750 commit 2d1a80d
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 308 deletions.
9 changes: 6 additions & 3 deletions lib/blog/calculate-blog-dest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const path = require('path');
const dateformat = require('dateformat');

exports.calculateBlogDest = function(project, metadata) {
let formattedDate = dateformat(metadata.publishedAt, 'yyyy/mm/dd');
const date = new Date(metadata.publishedAt);
let formattedDate = date.getUTCFullYear() + '/' +
// January gives 0
(date.getUTCMonth() + 1) + '/' +
date.getUTCDate();

return path.join(
project.blog.dest,
project.blog.dest,
formattedDate,
metadata.slug
);
Expand Down
12 changes: 6 additions & 6 deletions lib/page-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const fs = require('./file-system');
const path = require('path');

handlebars.registerPartial(
'functionOrMethod',
'functionOrMethod',
fs.readFileSync(require.resolve('./templates/partial-functionOrMethod.html')).toString()
);

handlebars.registerPartial(
'constantOrProperty',
'constantOrProperty',
fs.readFileSync(require.resolve('./templates/partial-constantOrProperty.html')).toString()
);

Expand All @@ -20,9 +20,9 @@ handlebars.registerHelper('formatDate', function(date) {
"November", "December"
];

var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();
var day = date.getUTCDate();
var monthIndex = date.getUTCMonth();
var year = date.getUTCFullYear();

return monthNames[monthIndex] + ' ' + day + ', ' + year;
});
Expand Down Expand Up @@ -87,7 +87,7 @@ function findAppSrc() {
if (path.startsWith('aurelia-docs') && path.endsWith('.js')) {
return path;
}
}
}

throw new Error('No app source found.');
}
Loading

0 comments on commit 2d1a80d

Please sign in to comment.