-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring. added format method to time-class. outputs time in a lan…
…guage-specific style (for now: english & german)
- Loading branch information
Showing
13 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module MessagesHelper | ||
|
||
def reply_message(old_message) | ||
new_message = " \n\n------------------------\n#{old_message.author.login} wrote (#{old_message.created_at.german :long}):\n_#{old_message.body}_" | ||
new_message = " \n\n------------------------\n#{old_message.author.login} wrote (#{old_message.created_at.format(:language => current_user.language, :format => :long)}):\n_#{old_message.body}_" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
# small enhancements to time class | ||
module TimeEnhancement | ||
|
||
def german(long_date = false) | ||
|
||
db_date = self.to_s(:db) | ||
date_en = db_date.split(" ")[0] | ||
time_en = db_date.split(" ")[1] | ||
|
||
date_split = date_en.split("-") | ||
time_split = time_en.split(":") | ||
|
||
hour = time_split[0] | ||
minute = time_split[1] | ||
|
||
day = date_split[2] | ||
month = date_split[1] | ||
year = date_split[0] | ||
|
||
if long_date == :long | ||
"#{day}.#{month}.#{year} - #{hour}:#{minute}" | ||
elsif long_date == :long_clock | ||
"#{day}.#{month}.#{year} - #{hour}:#{minute} Uhr" | ||
else | ||
"#{day}.#{month}.#{year}" | ||
end | ||
end | ||
def german(format = :short) | ||
case format | ||
when :long | ||
self.strftime("%d.%m.%Y - %H:%M") | ||
else | ||
self.strftime("%d.%m.%Y") | ||
end | ||
end | ||
|
||
def english(format = :short) | ||
case format | ||
when :long | ||
self.strftime("%m.%d.%Y - %H:%M") | ||
else | ||
self.strftime("%m.%d.%Y") | ||
end | ||
end | ||
|
||
def format(options = {}) | ||
lang = options[:lang] || Language.default | ||
format = options[:format] | ||
|
||
output = case lang | ||
when "de" | ||
german(format) | ||
when "en" | ||
english(format) | ||
end | ||
end | ||
|
||
end |