﻿var JavaScript = {};

Date.prototype.Days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

Date.prototype.GetDay = function() {
  return this.Days[this.getDay()];
};

Date.prototype.GetMonth = function() {
  return this.Months[this.getMonth()];
};

Date.prototype.GetOrdinal = function() {
  return (this.Ordinals[this.getDate()] || "th");
};

Date.prototype.Months = ["January", "February", "March", "April", "May", "June", "July", "August", "Spetember", "October", "November", "December"];

Date.prototype.Ordinals = { 1 : "st", 2 : "nd", 3 : "rd", 21 : "st", 22 : "nd", 23 : "rd", 31 : "st"};

Date.prototype.ToString = function() {
  return this.GetDay() + ", " + this.GetMonth() + " " + this.getDate() + this.GetOrdinal() + ", " + this.getFullYear();
};

String.prototype.Format = function() {
  var fval = this.toString();
  for (var i = 0; i < arguments.length; i++) {
    fval = fval.Replace("{" + i + "}", arguments[i]);
  };
  return fval;
}

String.prototype.Replace = function(rval, nval) {
  var val = this.toString();
  while (val.indexOf(rval) != -1) {
    val = val.replace(rval, nval);
  }
  return val;
};
