-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
customize changelog date format? #147
Comments
@seiyria you can customize your own templates if you are using a configuration file. Best bet might be using a module.exports = {
"template": {
"commit": "- [{{message}}]({{url}}) - @{{author}}",
"issue": "- {{labels}} {{name}} [{{text}}]({{url}})",
"label": "[**{{label}}**]",
"noLabel": "closed",
"group": "\n#### {{heading}}\n",
"changelogTitle": "# Changelog\n\n",
"release": function (placeholders) {
// Here you either set a new date with the desired format based on `placeholders.date`, ie:
// new Date(placeholders.date).toLocaleDateString("sv-SE");
// Or you just placeholders.replace(/\./,'-')
return `## ${placeholders.release}} (${placeholders.date})\n{{body}}`
},
"releaseSeparator": "\n---\n\n"
}
} |
Ah. I see. Thanks. I was hoping there's be a way to do it from a yml config
file instead (just to keep all of my configs in the same format).
…On Wed, Mar 7, 2018, 13:26 Alexander Vassbotn Røyne-Helgesen < ***@***.***> wrote:
@seiyria <https://github.com/seiyria> you can customize your own
templates if you are using a configuration file. Best bet might be using a
.grenrc.js file with something like this:
module.exports = {
"template": {
"commit": "- [{{message}}]({{url}}) - @{{author}}",
"issue": "- {{labels}} {{name}} [{{text}}]({{url}})",
"label": "[**{{label}}**]",
"noLabel": "closed",
"group": "\n#### {{heading}}\n",
"changelogTitle": "# Changelog\n\n",
"release": function (placeholders) {
// Here you either set a new date with the desired format based on `placeholders.date`, ie:
// new Date().toLocaleDateString("sv-SE");
// Or you just placeholders.replace(/\./,'-')
return `## ${placeholders.release}} (${placeholders.date})\n{{body}}`
},
"releaseSeparator": "\n---\n\n"
}
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAum2TmjyQ-QkO1cgGu2uy7Nfnz9Axqxks5tcDQFgaJpZM4SfKqe>
.
|
@seiyria perhaps you are looking for a feature to set the desired date format via options? Something like this? {
"template": {
"locale": "sv-SE",
...
}
} |
Hmm. I'm not sure about setting the locale. In all honesty it'd be nice to use a library like moment.js and just support their date parsing formats, so you could pass in mm/dd/yyyy or yyyy-mm-dd or whatever you wanted. If you wanted to add seconds for the timestamp for example. |
You rarely want to set the date format to anything other than the locale for the application, so why would you? What is the use case for this? You can do what you want, providing you use the correct locale: new Date(1520452614000).toLocaleDateString('sv-SE')
// Produces 2018-03-07 |
But, regardless, I support a feature to specify the date format, either by locale, or template strings |
Well, I stated my use case: changing the format of the date. I had no idea
that sv-SE formatted dates like that and that's not the first thing I'd
think of when trying to format a date. However, if that is how it would be configured
then that's fine.
…On Wed, Mar 7, 2018, 14:00 Alexander Vassbotn Røyne-Helgesen < ***@***.***> wrote:
You rarely want to set the date format to anything other than the locale
for the application, so why would you? What is the use case for this? You
can do what you want, providing you use the correct locale:
new Date(1520452614000).toLocaleDateString('sv-SE')// Produces 2018-03-07
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAum2V_UkTuybtwueSqDtlGbtoCE5IyWks5tcDxwgaJpZM4SfKqe>
.
|
Yeah, you can use |
Right, but I'd have to change formats. I'd prefer an option to set instead
of changing my config file to have code.
…On Thu, Mar 8, 2018, 02:53 Alexander Vassbotn Røyne-Helgesen < ***@***.***> wrote:
Yeah, you can use moment.js in that configuration file :=
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAum2aEvNzHG6FTEGJP9VRnGqxvL8VAfks5tcPFBgaJpZM4SfKqe>
.
|
Had to play around a little, but got this working with following template. There were a few pieces of @phun-ky code that needed tweaked
|
Honestly, it seems that there should be at least a basic option to use either the locale date or ISO 8601 date, which is the standard. |
@phun-ky I'm interested in adding support for locales and date formatting using the Intl.DateTimeFormat library. Do you have guidance on how you'd like to see that added? It feels like it would be an option, but the way options are set up in this tool, it seems a more natural fit would be a template. In either case, it also feels like it wouldn't be a good fit for |
Instead of DD/MM/YYYY, I'd like to use YYYY-MM-DD. I don't see an option for that.
The text was updated successfully, but these errors were encountered: