www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Display full date in French
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
Our data entry has short dates entered in English

eg. 13-Oct-2007

Is there a way to script the display in WebPublisher so that this date can display as its french full date equivalent.

13 octobre 2007

The software will only display the full date in English.

October 13, 2007

Most of our databases are english so we do not want to have french dates for all databases, rather only for those few that use them.
 
Posts: 153 | Registered: Tue June 08 2004Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Use the following to extend the javascript Date object with a "to French format" method. Get the English date string, use it to instantiate a new Date object, and call toLongFrenchFormat on it to get your date string à la français.

e.g. input "October 13, 2007" -> output "13 octobre 2007"


function Example()
{
	var strDateInEnglish = "October 13, 2007";
	var d = new Date(strDateInEnglish);
	var strDateInFrench = d.toLongFrenchFormat();
	return strDateInFrench;
}


Date.prototype.toLongFrenchFormat = function ()
{
	var months = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
	var date = this.getDate();
	if (date < 10)
	{
		date = "0" + date;	
	}
	var output = date + " " + months[this.getMonth()] + " " + this.getFullYear();
	return output;
}



Peter Tyrrell, MLIS
Senior Consultant
Andornot Consulting Inc.
http://www.andornot.com/about/developerblog
 
Posts: 179 | Location: Vancouver, BC, Canada | Registered: Thu September 20 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
I got it working with a few slight variations:

<script language = "javascript">
var monthsInYear= new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");

var myDateA = "DateCreated";

var myDate = new Date(myDateA);

var myString="<font face=\"arial\" color=\"black\">";
myString += myDate.getDate() + " ";
myString += monthsInYear[myDate.getMonth()] + " ";
myString += myDate.getFullYear();
myString += "</font>";
document.write(myString);
document.close()
</script>

All were treated as raw html and DateCreated field was raw html to avoid bold tags and was also date formated as long without day.
 
Posts: 153 | Registered: Tue June 08 2004Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Display full date in French