diff --git a/app/soapbox/components/birthday_input.js b/app/soapbox/components/birthday_input.js
index cb1408d51..36473dac8 100644
--- a/app/soapbox/components/birthday_input.js
+++ b/app/soapbox/components/birthday_input.js
@@ -39,8 +39,8 @@ class EditProfile extends ImmutablePureComponent {
if (!supportsBirthdays) return null;
- const maxDate = new Date();
- maxDate.setDate(maxDate.getDate() - minAge);
+ let maxDate = new Date();
+ maxDate = new Date(maxDate.getTime() - minAge * 1000 * 60 * 60 * 24 + maxDate.getTimezoneOffset() * 1000 * 60);
return (
@@ -56,6 +56,7 @@ class EditProfile extends ImmutablePureComponent {
wrapperClassName='react-datepicker-wrapper'
onChange={onChange}
placeholderText={intl.formatMessage(messages.birthdayPlaceholder)}
+ minDate={new Date('1900-01-01')}
maxDate={maxDate}
required={required}
/>
diff --git a/app/soapbox/features/auth_login/components/registration_form.js b/app/soapbox/features/auth_login/components/registration_form.js
index 127916a19..dbda945a8 100644
--- a/app/soapbox/features/auth_login/components/registration_form.js
+++ b/app/soapbox/features/auth_login/components/registration_form.js
@@ -223,7 +223,7 @@ class RegistrationForm extends ImmutablePureComponent {
}
if (birthday) {
- params.set('birthday', birthday.toISOString().slice(0, 10));
+ params.set('birthday', new Date(birthday.getTime() - (birthday.getTimezoneOffset() * 60000)).toISOString().slice(0, 10));
}
});
diff --git a/app/soapbox/features/edit_profile/index.js b/app/soapbox/features/edit_profile/index.js
index cf73ddbc4..8fe4ddd2b 100644
--- a/app/soapbox/features/edit_profile/index.js
+++ b/app/soapbox/features/edit_profile/index.js
@@ -125,7 +125,10 @@ class EditProfile extends ImmutablePureComponent {
map.set('hide_network', hidesNetwork(account));
map.set('discoverable', discoverable);
map.set('show_birthday', showBirthday);
- if (birthday) map.set('birthday', new Date(birthday));
+ if (birthday) {
+ const date = new Date(birthday);
+ map.set('birthday', new Date(date.getTime() + (date.getTimezoneOffset() * 60000)));
+ }
unescapeParams(map, ['display_name', 'bio']);
});
@@ -166,7 +169,9 @@ class EditProfile extends ImmutablePureComponent {
hide_follows: state.hide_network,
hide_followers_count: state.hide_network,
hide_follows_count: state.hide_network,
- birthday: state.birthday?.toISOString().slice(0, 10),
+ birthday: state.birthday
+ ? new Date(state.birthday.getTime() - (state.birthday.getTimezoneOffset() * 60000)).toISOString().slice(0, 10)
+ : undefined,
show_birthday: state.show_birthday,
}, this.getFieldParams().toJS());
}