lib/platformx/date.rb in platformx-0.0.9.6.2 vs lib/platformx/date.rb in platformx-0.0.9.6.3

- old
+ new

@@ -48,19 +48,32 @@ # Formats the date # @param date [Time] date representation in the format %A, %B %d, %Y # @param show_time [Boolean] if the timme should be incldued # @param show_month [Boolean] if teh month should be included # @return [String] formated representation of the given date - def x_format_date(date: "", show_time: false, show_month: true) + def x_format_date(date: "", show_time: false, show_month: true, format: "long") if date.nil? return "" else - time = date.strftime("%A, %B %d, %Y") - + + + if format == "mdy" + time = date.strftime("%m-%d-%Y") + elsif format == "d-m-y" + time = date.strftime("%d-%m-%Y") + elsif format == "m/d/y" + time = date.strftime("%D") + else + # Long format + time = date.strftime("%A, %B %d, %Y") + end + + # Show time if show_time == true time = time + date.strftime(" %l:%M %p") end - + + # Return time return time end end # Format date time