Skip to content

Commit a3d7f16

Browse files
authored
Merge pull request #2 from Testlio/monday-datetimepicker
Use Monday as week start by default
2 parents d360dc4 + 346da17 commit a3d7f16

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

dist/react-bootstrap-datetimepicker.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7459,11 +7459,6 @@ return /******/ (function(modules) { // webpackBootstrap
74597459
_react2.default.createElement(
74607460
"tr",
74617461
{ styleName: "day-of-week" },
7462-
_react2.default.createElement(
7463-
"th",
7464-
null,
7465-
"Su"
7466-
),
74677462
_react2.default.createElement(
74687463
"th",
74697464
null,
@@ -7493,6 +7488,11 @@ return /******/ (function(modules) { // webpackBootstrap
74937488
"th",
74947489
null,
74957490
"Sa"
7491+
),
7492+
_react2.default.createElement(
7493+
"th",
7494+
null,
7495+
"Su"
74967496
)
74977497
)
74987498
),
@@ -7540,12 +7540,13 @@ return /******/ (function(modules) { // webpackBootstrap
75407540
month = _this2.props.viewDate.month();
75417541
prevMonth = _this2.props.viewDate.clone().subtract(1, "months");
75427542
days = prevMonth.daysInMonth();
7543-
prevMonth.date(days).startOf("week");
7543+
prevMonth.date(days).startOf("isoweek");
75447544
nextMonth = (0, _moment2.default)(prevMonth).clone().add(42, "d");
75457545
minDate = _this2.props.minDate ? _this2.props.minDate.clone().subtract(1, "days") : _this2.props.minDate;
75467546
maxDate = _this2.props.maxDate ? _this2.props.maxDate.clone() : _this2.props.maxDate;
75477547
html = [];
75487548
cells = [];
7549+
75497550
while (prevMonth.isBefore(nextMonth)) {
75507551
var classes = {
75517552
day: true
@@ -7585,7 +7586,7 @@ return /******/ (function(modules) { // webpackBootstrap
75857586
onClick: _this2.handleDateClick.bind(_this2, !!classes.disabled) },
75867587
prevMonth.date()
75877588
));
7588-
if (prevMonth.weekday() === (0, _moment2.default)().endOf("week").weekday()) {
7589+
if (prevMonth.weekday() === (0, _moment2.default)().endOf("isoweek").weekday()) {
75897590
row = _react2.default.createElement(
75907591
"tr",
75917592
{ key: prevMonth.month() + "-" + prevMonth.date() },

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@testlio/react-bootstrap-datetimepicker",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "A bootstrap datetime picker component for React.js",
55
"homepage": "http://dev.quri.com/react-bootstrap-datetimepicker/",
66
"repository": {

src/components/DateTimePickerDays.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import classnames from "classnames";
44
import styles from '../css/date-time-picker-days.css';
55
import CSSModules from 'react-css-modules';
66
import NextPrevChanger from './next-prev-changer/next-prev-changer.js'
7-
7+
88
@CSSModules(styles, { allowMultiple: true })
99
export default class DateTimePickerDays extends Component {
1010
static propTypes = {
@@ -35,12 +35,13 @@ export default class DateTimePickerDays extends Component {
3535
month = this.props.viewDate.month();
3636
prevMonth = this.props.viewDate.clone().subtract(1, "months");
3737
days = prevMonth.daysInMonth();
38-
prevMonth.date(days).startOf("week");
38+
prevMonth.date(days).startOf("isoweek");
3939
nextMonth = moment(prevMonth).clone().add(42, "d");
4040
minDate = this.props.minDate ? this.props.minDate.clone().subtract(1, "days") : this.props.minDate;
4141
maxDate = this.props.maxDate ? this.props.maxDate.clone() : this.props.maxDate;
4242
html = [];
4343
cells = [];
44+
4445
while (prevMonth.isBefore(nextMonth)) {
4546
let classes = {
4647
day: true
@@ -73,12 +74,12 @@ export default class DateTimePickerDays extends Component {
7374
}
7475

7576
cells.push(
76-
<td key={prevMonth.month() + "-" + prevMonth.date()}
77-
className={classnames(classes)}
77+
<td key={prevMonth.month() + "-" + prevMonth.date()}
78+
className={classnames(classes)}
7879
styleName={classnames(classes)}
7980
onClick={this.handleDateClick.bind(this, !!classes.disabled)}>{prevMonth.date()}</td>
8081
);
81-
if (prevMonth.weekday() === moment().endOf("week").weekday()) {
82+
if (prevMonth.weekday() === moment().endOf("isoweek").weekday()) {
8283
row = <tr key={prevMonth.month() + "-" + prevMonth.date()}>{cells}</tr>;
8384
html.push(row);
8485
cells = [];
@@ -100,13 +101,13 @@ export default class DateTimePickerDays extends Component {
100101
{moment.months()[this.props.viewDate.month()]} {this.props.viewDate.year()}
101102
</NextPrevChanger>
102103
<tr styleName="day-of-week">
103-
<th>Su</th>
104104
<th>Mo</th>
105105
<th>Tu</th>
106106
<th>We</th>
107107
<th>Th</th>
108108
<th>Fr</th>
109109
<th>Sa</th>
110+
<th>Su</th>
110111
</tr>
111112
</thead>
112113

0 commit comments

Comments
 (0)