Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
362d78ba
Commit
362d78ba
authored
Nov 13, 2019
by
Miguel Rincon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused tick_formats file
echarts superseded the code here, so it can be removed
parent
9c0c5d01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
79 deletions
+0
-79
app/assets/javascripts/lib/utils/tick_formats.js
app/assets/javascripts/lib/utils/tick_formats.js
+0
-39
spec/javascripts/lib/utils/tick_formats_spec.js
spec/javascripts/lib/utils/tick_formats_spec.js
+0
-40
No files found.
app/assets/javascripts/lib/utils/tick_formats.js
deleted
100644 → 0
View file @
9c0c5d01
import
{
createDateTimeFormat
}
from
'
../../locale
'
;
let
dateTimeFormats
;
export
const
initDateFormats
=
()
=>
{
const
dayFormat
=
createDateTimeFormat
({
month
:
'
short
'
,
day
:
'
numeric
'
});
const
monthFormat
=
createDateTimeFormat
({
month
:
'
long
'
});
const
yearFormat
=
createDateTimeFormat
({
year
:
'
numeric
'
});
dateTimeFormats
=
{
dayFormat
,
monthFormat
,
yearFormat
,
};
};
initDateFormats
();
/**
Formats a localized date in way that it can be used for d3.js axis.tickFormat().
That is, it displays
- 4-digit for first of January
- full month name for first of every month
- day and abbreviated month otherwise
see also https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Axes.md#tickFormat
*/
export
const
dateTickFormat
=
date
=>
{
if
(
date
.
getDate
()
!==
1
)
{
return
dateTimeFormats
.
dayFormat
.
format
(
date
);
}
if
(
date
.
getMonth
()
>
0
)
{
return
dateTimeFormats
.
monthFormat
.
format
(
date
);
}
return
dateTimeFormats
.
yearFormat
.
format
(
date
);
};
spec/javascripts/lib/utils/tick_formats_spec.js
deleted
100644 → 0
View file @
9c0c5d01
import
{
dateTickFormat
,
initDateFormats
}
from
'
~/lib/utils/tick_formats
'
;
import
{
setLanguage
}
from
'
../../helpers/locale_helper
'
;
describe
(
'
tick formats
'
,
()
=>
{
describe
(
'
dateTickFormat
'
,
()
=>
{
beforeAll
(()
=>
{
setLanguage
(
'
de
'
);
initDateFormats
();
});
afterAll
(()
=>
{
setLanguage
(
null
);
});
it
(
'
returns year for first of January
'
,
()
=>
{
const
tick
=
dateTickFormat
(
new
Date
(
'
2001-01-01
'
));
expect
(
tick
).
toBe
(
'
2001
'
);
});
it
(
'
returns month for first of February
'
,
()
=>
{
const
tick
=
dateTickFormat
(
new
Date
(
'
2001-02-01
'
));
expect
(
tick
).
toBe
(
'
Februar
'
);
});
it
(
'
returns day and month for second of February
'
,
()
=>
{
const
tick
=
dateTickFormat
(
new
Date
(
'
2001-02-02
'
));
expect
(
tick
).
toBe
(
'
2. Feb.
'
);
});
it
(
'
ignores time
'
,
()
=>
{
const
tick
=
dateTickFormat
(
new
Date
(
'
2001-02-02 12:34:56
'
));
expect
(
tick
).
toBe
(
'
2. Feb.
'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment