Compare commits

...

3 Commits

Author SHA1 Message Date
fe6fa9480a Release 5.0.1 2024-08-23 15:42:48 +02:00
6cb51a3841 Remove unused parameters in MailPoet.date.toDate
The options were just set in init but there was no effect.
[MAILPOET-6197]
2024-08-23 15:37:16 +02:00
122f73c3c2 Do not apply offset when manipulating with date in the Date picker
We use DateTime component on the send page.
The DateTime component uses DateText for picking date.
We add site's offset before we pass the date to the DateTime.

The date-text component is nested in the DateTime and was also applying
offset on the date.

The second issue was we needed to convert the value to JS Date.
The MailPoet.Date.toDate expects the value to be in UTC, and we provided an already converted date.

So for offset -07:00
MailPoet.Date.toDate('2023-09-01');
ends up
Thu Aug 31 2023 17:00:00 GMT-0700 (Pacific Daylight Time) and calendar display's incorrect value.

This commit fixes it so that we don't touch offset in the DateText component.
[MAILPOET-6197]
2024-08-23 15:37:07 +02:00
5 changed files with 16 additions and 25 deletions

View File

@ -1,5 +1,9 @@
== Changelog == == Changelog ==
= 5.0.1 - 2024-08-23 =
- Fixed: incorrect date in the scheduling calendar on the send page.
= 5.0.0 - 2024-08-19 = = 5.0.0 - 2024-08-19 =
- Changed: replaced PDO database connection in favor of WordPress's native wpdb; - Changed: replaced PDO database connection in favor of WordPress's native wpdb;

View File

@ -69,9 +69,7 @@ export const MailPoetDate: {
} }
return momentDate.format(this.convertFormat(this.options.format)); return momentDate.format(this.convertFormat(this.options.format));
}, },
toDate: function toDate(date: MomentInput, opts?: DateOptions): Date { toDate: function toDate(date: MomentInput): Date {
const options = opts || {};
this.init(options);
return Moment.utc(date).toDate(); return Moment.utc(date).toDate();
}, },
short: function short(date: MomentInput): string { short: function short(date: MomentInput): string {

View File

@ -1,10 +1,10 @@
import { Component, SyntheticEvent } from 'react'; import { Component, SyntheticEvent } from 'react';
import Moment from 'moment';
import { __, _x } from '@wordpress/i18n'; import { __, _x } from '@wordpress/i18n';
import { registerLocale } from 'react-datepicker'; import { registerLocale } from 'react-datepicker';
import locale from 'date-fns/locale/en-US'; import locale from 'date-fns/locale/en-US';
import { Datepicker } from 'common/datepicker/datepicker'; import { Datepicker } from 'common/datepicker/datepicker';
import { MailPoet } from 'mailpoet'; import { MailPoet } from 'mailpoet';
import { DateOptions } from 'date';
/** /**
* This function is a copy of the buildLocalizeFn function from date-fns (date-fns/locale/_lib/buildLocalizeFn) * This function is a copy of the buildLocalizeFn function from date-fns (date-fns/locale/_lib/buildLocalizeFn)
@ -134,10 +134,10 @@ class DateText extends Component<DateTextProps> {
onChange = (value: Date, event) => { onChange = (value: Date, event) => {
const changeEvent: DateTextEvent = event; const changeEvent: DateTextEvent = event;
// Swap display format to storage format // Swap display format to storage format
const storageDate = this.getStorageDate(value); const formattedDate = this.getAsStringInFormat(value);
changeEvent.target.name = this.getFieldName(); changeEvent.target.name = this.getFieldName();
changeEvent.target.value = storageDate; changeEvent.target.value = formattedDate;
this.props.onChange(changeEvent); this.props.onChange(changeEvent);
}; };
@ -155,19 +155,10 @@ class DateText extends Component<DateTextProps> {
.replace(/\]/g, ''); .replace(/\]/g, '');
}; };
getDate = (date: string) => { getDate = (date: string) => Moment(date).toDate();
const formatting = {
parseFormat: this.props.storageFormat,
} as DateOptions;
return MailPoet.Date.toDate(date, formatting);
};
getStorageDate = (date: Date) => { getAsStringInFormat = (date: Date) =>
const formatting = { Moment(date).format(MailPoet.Date.convertFormat(this.props.storageFormat));
format: this.props.storageFormat,
};
return MailPoet.Date.format(date, formatting);
};
render() { render() {
return ( return (

View File

@ -2,7 +2,7 @@
/* /*
* Plugin Name: MailPoet * Plugin Name: MailPoet
* Version: 5.0.0 * Version: 5.0.1
* Plugin URI: https://www.mailpoet.com * Plugin URI: https://www.mailpoet.com
* Description: Create and send newsletters, post notifications and welcome emails from your WordPress. * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
* Author: MailPoet * Author: MailPoet
@ -20,7 +20,7 @@
*/ */
$mailpoetPlugin = [ $mailpoetPlugin = [
'version' => '5.0.0', 'version' => '5.0.1',
'filename' => __FILE__, 'filename' => __FILE__,
'path' => dirname(__FILE__), 'path' => dirname(__FILE__),
'autoloader' => dirname(__FILE__) . '/vendor/autoload.php', 'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',

View File

@ -3,7 +3,7 @@ Contributors: mailpoet, woocommerce, automattic
Tags: email marketing, post notification, woocommerce emails, email automation, newsletter Tags: email marketing, post notification, woocommerce emails, email automation, newsletter
Requires at least: 6.5 Requires at least: 6.5
Tested up to: 6.6 Tested up to: 6.6
Stable tag: 5.0.0 Stable tag: 5.0.1
Requires PHP: 7.4 Requires PHP: 7.4
License: GPLv3 License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -229,9 +229,7 @@ Check our [Knowledge Base](https://kb.mailpoet.com) or contact us through our [s
== Changelog == == Changelog ==
= 5.0.0 - 2024-08-19 = = 5.0.1 - 2024-08-23 =
* Changed: replaced PDO database connection in favor of WordPress's native wpdb; * Fixed: incorrect date in the scheduling calendar on the send page.
* Fixed: dual buttons in MS Outlook;
* Fixed: false error notice about MSS connection for editor users.
[See the changelog for all versions.](https://github.com/mailpoet/mailpoet/blob/trunk/mailpoet/CHANGELOG.md) [See the changelog for all versions.](https://github.com/mailpoet/mailpoet/blob/trunk/mailpoet/CHANGELOG.md)