Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Birthday trails one day behind

This discussion is related to the AboutMe addon.

Hi,

Thanks for this wonderful plugin. I have one issue, which is that the birthday always displays as 1 day behind what was chosen. For example, my B-day is December 2nd, but on my profile it is displayed as December 1st.

I am using a new install of vanilla 2.0.18.8 and the latest version of the plugin. Any insight would be much appreciated!

Comments

  • Okay, I think I found the issue. Birthdays were showing correctly in some time zones and not others. Although this caused people on one side of the planet to wish someone happy birthday at the right time, when it came up in conversation they always referenced the wrong day, and this caused more stress than it was worth. Felt very non-intuitive to me and everyone.

    This is a very quick and dirty fix, but if you want to make the birthday output exactly as users have entered it regardless of the time zone it is being viewed in, open up your vanilla folder, plugins, AboutMe, views, and open the file aboutme_view.php

    Find this line of code: <?php if ($this->AboutMe->HideBD != '1') {

    From there to here: echo $Birthday; ?>

    Replace with this:

    <?php if ($this->AboutMe->HideBD != '1') { $birthdayPieces = explode("-", $this->AboutMe->BD); $monthNum = $birthdayPieces[1]; $monthName = date("F", mktime(0, 0, 0, $monthNum, 10)); $day = ltrim($birthdayPieces[2], '0'); ?> <div class="row"> <div class="label">Birthday:</div> <div class="data"><?php if ($this->AboutMe->HideBY == '1') { //$Birthday = Gdn_Format::Date($this->AboutMe->BD, T('Date.DefaultDayFormat', '%B %e')); $Birthday = $monthName . " " . $day; } else { // $Birthday = Gdn_Format::Date($this->AboutMe->BD, T('Date.DefaultFormat', '%B %e, %Y')); $Birthday = $monthName . " " . $day . ", " . $birthdayPieces[0]; } echo $Birthday; ?>

    I'm sure someone could make this more efficient and cleaner, but it does work. Hope this helps someone else out there!

  • hgtonighthgtonight ∞ · New Moderator

    I don't think I have seen you before, welcome to the community!

    I can confirm that I also see this same issue on a fresh install of Vanilla 2.0.18.8.

    Looking into this specific issue, it appears to save the date correctly in the db. It also retrieves it correctly. I can't figure it out, but it looks like an issue with how the date is modified in Gdn_Format::Date().

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Thanks for the welcome! I can confirm that it saved correctly in my DB and retrieved correctly as well, which is why I wrote that snippet to just output exactly what it saw and skip the Gdn_Format entirely.

  • hgtonighthgtonight ∞ · New Moderator

    So it ends up being a configuration issue.

    The fix would be to replace line 83 in /plugins/AboutMe/views/aboutme_view.php with $Birthday = strftime(T('AboutMe.BirthdayFormatHiddenYear','%B %d'), strtotime($this->AboutMe->BD)); and line 86 with $Birthday = strftime(T('AboutMe.BirthdayFormat','%B %d, %Y'), strtotime($this->AboutMe->BD));

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    PIXELovely
  • Great to see your solution! Thanks, I'm new to modding Vanilla.

    businessdad
  • Hello, sorry guys, I have been inactive in the community for a while now, though I still am developing when I can for vanilla (I have some serious applications in the making). Sorry it took me a few days to get back to you on that. I am surprised that there is still interest in this plugin, as some other users have made similar plugins, and I have seen one included in the latest version of Vanilla.

    I am stuck on a machine not at all made for developing right now (just running Firefox freezes), Or I would immediately update this; however I will be acquiring a new system in the next week or so, and plan on returning to Vanilla full force.

    This code is also available on Github, you could make the corrections and issue a pull request, if you like. https://github.com/DMeganoski/About-Me

    Thanks

    hgtonight
  • Very understandable, zodiacdm! Hope you get access to a better computer soon. :)

Sign In or Register to comment.