Skip to content
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

Update date_utils.js #19

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
229a0a5
Bump sshpk from 1.13.1 to 1.16.1
dependabot[bot] Jun 19, 2020
3dc56dd
Bump y18n from 3.2.1 to 3.2.2
dependabot[bot] Mar 30, 2021
05f4d06
Bump hosted-git-info from 2.5.0 to 2.8.9
dependabot[bot] May 10, 2021
a7ba988
Bump path-parse from 1.0.5 to 1.0.7
dependabot[bot] Aug 10, 2021
3270f34
(feature): add italian month names
Oct 14, 2021
9cf9ebb
Bump merge from 1.2.0 to 1.2.1
dependabot[bot] Apr 28, 2022
8b396e4
Bump extend from 3.0.1 to 3.0.2
dependabot[bot] Apr 28, 2022
5b32687
Bump lodash from 4.17.5 to 4.17.21
dependabot[bot] Apr 28, 2022
9744be6
Bump tmpl from 1.0.4 to 1.0.5
dependabot[bot] Apr 28, 2022
b038464
Bump tar from 2.2.1 to 2.2.2
dependabot[bot] Apr 28, 2022
e095e4c
Bump ini from 1.3.5 to 1.3.8
dependabot[bot] Apr 28, 2022
481896e
fix: exception when moving invalid bar
hiawui Jun 24, 2022
c6e0b50
fix: wrong thick stick in view mode 'Month'
hiawui Jun 29, 2022
393b006
Bump qs from 6.4.0 to 6.4.1
dependabot[bot] Dec 7, 2022
073bc25
Merge pull request #301 from frappe/dependabot/npm_and_yarn/qs-6.4.1
s-aga-r Dec 29, 2022
469dfa3
Merge pull request #267 from frappe/dependabot/npm_and_yarn/ini-1.3.8
s-aga-r Dec 30, 2022
351fce3
Merge pull request #158 from frappe/dependabot/npm_and_yarn/extend-3.0.2
s-aga-r Dec 30, 2022
cd56d6e
Merge pull request #159 from frappe/dependabot/npm_and_yarn/merge-1.2.1
s-aga-r Dec 30, 2022
1e1498f
Merge pull request #218 from frappe/dependabot/npm_and_yarn/y18n-3.2.2
s-aga-r Dec 30, 2022
d12cc0d
Merge pull request #227 from frappe/dependabot/npm_and_yarn/lodash-4.…
s-aga-r Dec 30, 2022
626bf6a
Merge pull request #228 from frappe/dependabot/npm_and_yarn/hosted-gi…
s-aga-r Dec 30, 2022
9ce1e99
Merge pull request #241 from frappe/dependabot/npm_and_yarn/tmpl-1.0.5
s-aga-r Dec 30, 2022
bfadf65
Merge pull request #161 from frappe/dependabot/npm_and_yarn/sshpk-1.16.1
s-aga-r Jan 2, 2023
da4b313
Merge pull request #239 from frappe/dependabot/npm_and_yarn/path-pars…
s-aga-r Jan 2, 2023
372b1e8
Merge pull request #238 from frappe/dependabot/npm_and_yarn/tar-2.2.2
s-aga-r Jan 2, 2023
781578c
chore: align heading center in `index.html`
s-aga-r Jan 4, 2023
fc08a80
chore: use arrow functions in `index.html`
s-aga-r Jan 4, 2023
33cb615
Merge pull request #302 from DennisAnim/dennisGantt-Repo
s-aga-r Jan 4, 2023
73871b0
chore: add `language` option in `README.md`
s-aga-r Dec 14, 2022
228782a
Merge pull request #292 from ThibaultBarolat/add-language-option-doc
s-aga-r Jan 4, 2023
94fdb10
Merge pull request #279 from hiawui/bugfix-month-mode-thick-tick
s-aga-r Jan 4, 2023
80458f6
Merge pull request #271 from hiawui/bugfix-invalid-bar
s-aga-r Jan 4, 2023
743f84f
Merge pull request #242 from SergAlexAnd/master
s-aga-r Jan 4, 2023
e014234
chore: update `language` options in `README.md`
s-aga-r Jan 4, 2023
bf80b07
Merge pull request #306 from s-aga-r/it-language-in-readme
s-aga-r Jan 4, 2023
342e97b
feat: add support for german and hungarian languages
s-aga-r Jan 6, 2023
7381b84
chore: update language options in README.md
s-aga-r Jan 6, 2023
0381503
Merge pull request #307 from s-aga-r/feat/languages
s-aga-r Jan 7, 2023
ddb3572
chore: use `Intl.DateTimeFormat` to translate month names
stephanvierkant Jan 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var gantt = new Gantt("#gantt", tasks, {
padding: 18,
view_mode: 'Day',
date_format: 'YYYY-MM-DD',
language: 'en', // or 'es', 'it', 'ru', 'ptBr', 'fr', 'tr', 'zh', 'de', 'hu'
custom_popup_html: null
});
```
Expand Down
121 changes: 13 additions & 108 deletions dist/frappe-gantt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/frappe-gantt.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/frappe-gantt.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/frappe-gantt.min.js.map

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
.gantt .bar-milestone .bar {
fill: tomato;
}
.heading {
text-align: center;
}
</style>
<link rel="stylesheet" href="dist/frappe-gantt.css" />
<script src="dist/frappe-gantt.js"></script>
</head>
<body>
<div class="container">
<h2>Interactive Gantt Chart entirely made in SVG!</h2>
<h2 class="heading">Interactive Gantt Chart entirely made in SVG!</h2>
<div class="gantt-target"></div>
</div>
<script>
Expand Down Expand Up @@ -84,16 +87,16 @@ <h2>Interactive Gantt Chart entirely made in SVG!</h2>
}
]
var gantt_chart = new Gantt(".gantt-target", tasks, {
on_click: function (task) {
on_click: task => {
console.log(task);
},
on_date_change: function(task, start, end) {
on_date_change: (task, start, end) => {
console.log(task, start, end);
},
on_progress_change: function(task, progress) {
on_progress_change: (task, progress) => {
console.log(task, progress);
},
on_view_change: function(mode) {
on_view_change: (mode) => {
console.log(mode);
},
view_mode: 'Month',
Expand Down
2 changes: 2 additions & 0 deletions src/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export default class Bar {
}

update_progressbar_position() {
if (this.invalid) return;
this.$bar_progress.setAttribute('x', this.$bar.getX());
this.$bar_progress.setAttribute(
'width',
Expand All @@ -389,6 +390,7 @@ export default class Bar {
}

update_handle_position() {
if (this.invalid) return;
const bar = this.$bar;
this.handle_group
.querySelector('.handle.left')
Expand Down
114 changes: 10 additions & 104 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,107 +6,6 @@ const MINUTE = 'minute';
const SECOND = 'second';
const MILLISECOND = 'millisecond';

const month_names = {
en: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
es: [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre',
],
ru: [
'Январь',
'Февраль',
'Март',
'Апрель',
'Май',
'Июнь',
'Июль',
'Август',
'Сентябрь',
'Октябрь',
'Ноябрь',
'Декабрь',
],
ptBr: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
fr: [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre',
],
tr: [
'Ocak',
'Şubat',
'Mart',
'Nisan',
'Mayıs',
'Haziran',
'Temmuz',
'Ağustos',
'Eylül',
'Ekim',
'Kasım',
'Aralık',
],
zh: [
'一月',
'二月',
'三月',
'四月',
'五月',
'六月',
'七月',
'八月',
'九月',
'十月',
'十一月',
'十二月',
],
};

export default {
parse(date, date_separator = '-', time_separator = /[.:]/) {
if (date instanceof Date) {
Expand Down Expand Up @@ -161,7 +60,14 @@ export default {
},

format(date, format_string = 'YYYY-MM-DD HH:mm:ss.SSS', lang = 'en') {
const values = this.get_date_values(date).map((d) => padStart(d, 2, 0));
const dateTimeFormat = new Intl.DateTimeFormat(lang, {
month: 'long'
});
const month_name = dateTimeFormat.format(date);
const month_name_capitalized =
month_name.charAt(0).toUpperCase() + month_name.slice(1);

const values = this.get_date_values(date).map(d => padStart(d, 2, 0));
const format_map = {
YYYY: values[0],
MM: padStart(+values[1] + 1, 2, 0),
Expand All @@ -171,8 +77,8 @@ export default {
ss: values[5],
SSS: values[6],
D: values[2],
MMMM: month_names[lang][+values[1]],
MMM: month_names[lang][+values[1]],
MMMM: month_name_capitalized,
MMM: month_name_capitalized,
};

let str = format_string;
Expand Down
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,7 @@ export default class Gantt {
tick_class += ' thick';
}
// thick ticks for quarters
if (
this.view_is(VIEW_MODE.MONTH) &&
(date.getMonth() + 1) % 3 === 0
) {
if (this.view_is(VIEW_MODE.MONTH) && date.getMonth() % 3 === 0) {
tick_class += ' thick';
}

Expand Down
Loading