From b3c63a3cc06ccb509bd437d5ca975b000f37c020 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 17 Dec 2010 18:05:13 -0800 Subject: [PATCH] you can now unset the year of your birthday" --- app/helpers/people_helper.rb | 8 ++++++++ app/models/profile.rb | 5 +++-- app/views/people/_profile_sidebar.html.haml | 3 +-- config/locales/diaspora/en.yml | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 4711433ed..03f5e47b8 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -19,4 +19,12 @@ module PeopleHelper I18n.t "people.helper.people_on_pod_are_aware_of" end end + + def birthday_format(bday) + if bday.year == 1000 + bday.strftime("%B %d") + else + bday.strftime("%B %d %Y") + end + end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 2e66fc37e..122159285 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -88,10 +88,11 @@ class Profile end def date= params - if ['year', 'month', 'day'].all? { |key| params[key].present? } + params['year'] = '1000' if params['year'].blank? + if ['month', 'day'].all? { |key| params[key].present? } date = Date.new(params['year'].to_i, params['month'].to_i, params['day'].to_i) self.birthday = date - elsif ['year', 'month', 'day'].all? { |key| params[key] == '' } + elsif ['month', 'day'].all? { |key| params[key].blank? } self.birthday = nil end end diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml index 892d15146..716ec4681 100644 --- a/app/views/people/_profile_sidebar.html.haml +++ b/app/views/people/_profile_sidebar.html.haml @@ -54,5 +54,4 @@ - unless person.profile.birthday.blank? %h3 =t('.born') - = t('ago', :time => time_ago_in_words(person.profile.birthday)) if @person.profile.birthday - + = birthday_format(person.profile.birthday) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index a4a899678..f7306f509 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -366,7 +366,7 @@ en: edit_my_profile: "Edit my profile" bio: "bio" gender: "gender" - born: "born" + born: "birthday" in_aspects: "in aspects" cannot_remove: "Cannot remove %{name} from last aspect. (If you want to disconnect from this person you must remove contact.)" remove_from: "Remove %{name} from %{aspect}?"