/**
 * THE DisplayText.java WRITEME...
 */
package com.tootsville.tootsbook.client.util;

import java.util.Date;

/**
 * WRITEME: Document this type. twheys@gmail.com Jan 13, 2010
 * 
 * @author <a href="mailto:twheys@gmail.com@resinteractive.com">Tim
 *         Heys</a>
 */
public class DisplayText {
	
	/**
	 *
	 */
	public static final String ADD_COMMENT = "Reply!";
	/**
	 *
	 */
	public static final String ALREADY_HAVE_ITEM = "You already have that item!";
	/**
	 *
	 */
	public static final String ARE_YOU_SURE_REPORT = "Are you sure you want to report this Toot to a Moderator?";
	
	/**
	 *
	 */
	public static final String AVATAR_BACKGROUND_TEXT = "Player Card";
	
	/**
	 *
	 */
	public static final String BOX_STYLE_TEXT = "Profile Theme";
	
	/**
	 *
	 */
	public static final String CANNOT_AFFORD_ITEM = "You do not have enough peanuts for that!  Earn peanuts by playing games in Tootsville.";
	
	/**
	 *
	 */
	public static final String COMMENT_DELETE_TITLE = "Delete this comment";
	
	/**
	 *
	 */
	public static final String COMMENT_FIELD_DEFAULT_TEXT = "Leave a comment!";
	
	/**
	 *
	 */
	public static final String DEFAULT_SEARCH_TEXT = "Search...";
	
	/**
	 *
	 */
	public static final String DELETE_TITLE = "Delete This Post";
	/**
	 *
	 */
	public static final String ERROR_404 = "Oops!  Looks like that page doesn't exist.";

	/**
	 *
	 */
	public static final String ERROR_HEADER = "Sorry, an Error has occurred.";
	
	/**
	 *
	 */
	public static final String ICON_TEXT = "Buddy Icon";
	
	/**
	 *
	 */
	public static final String LEAVE_A_MESSAGE = "Leave a message!";
	
	/**
	 *
	 */
	public static final String LOADING_COMMENTS = "Comments are loading...";
	
	/**
	 *
	 */
	public static final String LOG_IN_FOR_COMMENT = "Log in to leave me a comment";
	
	/**
	 *
	 */
	public static final String LOG_IN_FOR_POST = "Log in to post on my wall";
	
	/**
	 *
	 */
	public static final String LOGGED_IN_FOR_COMMENTS = "You must be logged in to leave posts.";
	
	/**
	 *
	 */
	public static final String MAKE_A_POST = "Make a new post!";
	
	/**
	 *
	 */
	public static final String NO_MORE_ITEMS = "You don't have any items! "
			+ "Purchase themes at the Toots Mall.";
	
	/**
	 *
	 */
	public static final String PAGE_BACKGROUND_TEXT = "Wallpaper";
	
	/**
	 *
	 */
	public static final String REPORT_TITLE = "Report This Post";
	
	/**
	 *
	 */
	public static final String REPORT_TOOT_TITLE = "Report this Toot.";

	/**
	 * The message displayed to the user when the server cannot be
	 * reached or returns an error.
	 */
	public static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";
	
	/**
	 *
	 */
	public static final String SHOW_MORE_POSTS = "Show More Posts";
	/**
	 *
	 */
	public static final String STORE_ICON = "TootsBook Icon";
	/**
	 *
	 */
	public static final String STORE_NAME_TAG = "Name Tag";
	/**
	 *
	 */
	public static final String STORE_PLAYER_CARD = "Player Card";
	/**
	 *
	 */
	public static final String STORE_PROFILE_THEME = "Profile Theme";
	/**
	 *
	 */
	public static final String STORE_WALLPAPER = "Wallpaper";
	/**
	 *
	 */
	public static final String TITLE_BACKGROUND_TEXT = "Name Tag";
	
	/**
	 *
	 */
	public static final String WRITE_ON_MY_WALL = "What are you doing?";
	
	/**
	 *
	 */
	public static final String WRITE_ON_YOUR_WALL = "Write something on my wall!";

	/**
	 * @param targetDate a date in the future
	 * @return a human-legible expression describing the time in the
	 *         future
	 */
	public static String formatFutureDate_English (final Date targetDate) {
		final Date now = new Date ();
		if (targetDate.compareTo (now) < 0) {
			return "the past";
		}
		if (targetDate.compareTo (now) == 0) {
			return "right now";
		}

		final long diffSec = targetDate.getTime () - now.getTime ();

		if (diffSec <= 0) {
			return "already";
		}

		if (diffSec == 1) {
			return "a second from now";
		}

		if (diffSec < 6) {
			return "a few seconds from now";
		}

		if (diffSec < 60) {
			return "" + diffSec + " seconds from now";
		}

		if (diffSec < 180) {
			final long remSec = diffSec - 60;
			return "a minute and " + diffSec + " second"
					+ (remSec > 1 ? "s" : "") + " from now";
		}

		if (diffSec < 60 * 90) {
			return "" + (int) (diffSec / 60) + " minutes from now";
		}

		if (diffSec < 60 * 60 * 36) {
			final long hours = diffSec / (60 * 60);
			final long minutes = diffSec % (60 * 60) / (60 * 15) * 15;
			return "about " + hours + " hours and " + minutes
					+ " minutes from now";
		}

		final long days = diffSec / (60 * 60 * 24);
		return "about " + days + " days from now";
	}

	/**
	 * @param timeMillis a time in the past in Milliseconds
	 * @return a human-legible expression describing the time in the
	 *         future
	 */
	public static String formatPastDate_English (final long timeMillis) {
		final long now = System.currentTimeMillis () / 1000;
		final long then = timeMillis / 1000;

		final long diffSec = now - then;

		if (diffSec < 6) {
			return "Just now";
		}

		if (diffSec < 60) {
			return "Less than a minute ago";
		}

		if (diffSec < 120) {
			return "A minute ago";
		}

		if (diffSec < 60 * 60) {
			final long minutes = diffSec / 60;
			final String plural = 1 == minutes ? "minute" : "minutes";
			return "" + minutes + " " + plural + " ago";
		}

		if (diffSec < 60 * 60 * 24) {
			final long hours = diffSec / (60 * 60);
			final String plural = 1 == hours ? "hour" : "hours";
			return "" + hours + " " + plural + " ago";
		}

		if (diffSec < 60 * 60 * 24 * 30) {
			final long days = diffSec / (60 * 60 * 24);
			final String plural = 1 == days ? "day" : "days";
			return "" + days + " " + plural + " ago";
		}

		if (diffSec < 60 * 60 * 24 * 30 * 12) {
			final long months = diffSec / (60 * 60 * 24 * 30);
			final String plural = 1 == months ? "month" : "months";
			return "" + months + " " + plural + " ago";
		}

		final long years = diffSec / (60 * 60 * 24 * 30 * 12);
		final String plural = 1 == years ? "year" : "years";
		return "" + years + " " + plural + " ago";
	}
}
