Fix timezone conversion.
parent
57ada5e0ed
commit
3bebe84243
12
src/App.jsx
12
src/App.jsx
|
@ -20,15 +20,19 @@ WebFont.load({
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
getNow: PropTypes.func,
|
getNow: PropTypes.func,
|
||||||
weekdays: PropTypes.arrayOf(PropTypes.string),
|
weekdays: PropTypes.arrayOf(
|
||||||
|
PropTypes.oneOfType([
|
||||||
|
PropTypes.string,
|
||||||
|
PropTypes.number,
|
||||||
|
])),
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
getNow: () => moment(),
|
getNow: () => moment(),
|
||||||
weekdays: [
|
weekdays: [
|
||||||
'tuesday',
|
2,
|
||||||
'thursday',
|
4,
|
||||||
'saturday',
|
6,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
export default function getUpcomingDate(now, weekday: String) {
|
const localTimeZone = moment.tz.guess();
|
||||||
|
|
||||||
|
export default function getUpcomingDate(now, weekday: String|Number) {
|
||||||
let wanted = moment()
|
let wanted = moment()
|
||||||
.tz('CET')
|
.tz('CET')
|
||||||
.isoWeekday(weekday)
|
.isoWeekday(weekday)
|
||||||
.second(0)
|
.second(0)
|
||||||
.minute(0)
|
.minute(0)
|
||||||
.hour(0);
|
.hour(0)
|
||||||
|
.tz(localTimeZone);
|
||||||
|
|
||||||
if (wanted.isBefore(now)) {
|
if (wanted.isBefore(now)) {
|
||||||
// we want the date from the upcoming week
|
// we want the date from the upcoming week
|
||||||
|
|
Loading…
Reference in New Issue