Covert date to french

Posted by: Luc

Covert date to french - 08/27/20 12:23 PM

Hi,
How can I convert my system date Thursday, August 27, 2020 to french: 27 Août 2020. ?

Thanks
Posted by: Jean-Cédric

Re: Covert date to french - 08/27/20 12:30 PM

Since the Date() function in PressTalk will use the language of the Regional system where the form is executed, you would need to do it via a script in Workflow prior to executing your form.
Then pass the formatted date as a variable or jobinfo to the form.
Posted by: Luc

Re: Covert date to french - 08/27/20 12:33 PM

Can it be done in desing without workflow?

thanks
Posted by: Jean-Cédric

Re: Covert date to french - 08/27/20 01:15 PM

Yes but that would require a PressTalk that takes your date and convert it to its french counterpart. Since there is no such function, you would have to build it from scratch.

Now you say "...without workflow...". If the date is already in the data, then yes. But know that the Date() function cannot work in a printer as there is no system date.
Posted by: jouberto

Re: Covert date to french - 08/27/20 01:39 PM

There is a provided set of functions in our presstalk libraries that will do precisely that in Design, without workflow, in French.

Let me know if you cannot find them or I will try to provide as many details as possible
Posted by: jouberto

Re: Covert date to french - 08/27/20 01:40 PM

http://planetpress.objectiflune.com/content/files/planetpress/Libraries_Functions_Date.zip
Posted by: jouberto

Re: Covert date to french - 08/27/20 01:42 PM

you will want to import in your document the following functions:
- Normalize date
- GetDayNameF
- GetMonthNameF
- FormatDateF
Posted by: jouberto

Re: Covert date to french - 08/27/20 01:45 PM

Another way to do this, since you already have the fully spelled days and months in english, would be to build arrays of days and months, in french and english, and find the position of the current english day and month from your data, and pull the value from the corresponding position in the french array to display on the form. A bit of work but not too complex.
Posted by: Jean-Cédric

Re: Covert date to french - 08/27/20 01:46 PM

Ah!...good to know...thanks @jouberto
Posted by: Luc

Re: Covert date to french - 08/27/20 02:49 PM

Thanks

I now have the functions But I don't know how to use them

Would you have a code sample I could look into
I just want to write the date of the day on a letter in english or french depending on language

thanks
Posted by: jouberto

Re: Covert date to french - 08/27/20 03:29 PM

Hi Luc,

I will try to upload screenshots showing the right order to place the functions in the list and a syntax example to use them. These functions require you pass as a parameter the date format. As J-C mentioned at the top of the thread, the Date() function I use in my call for today's date, will have a format based on regional settings. Mine are set to YYYY-MM-DD, but yours could be different, just match what you have when writing the call to the function.
Posted by: jouberto

Re: Covert date to french - 08/27/20 03:42 PM

Putting these lines in a custom data selection will produce the desired dates in English and French. I couldn't find an online repository so I can link my screenshots to you, so I can only give you the below tips.

Code:
=@FormatDate(Date(false),'YYYY-MM-DD')

Code:
=@FormatDateF(Date(false),'YYYY-MM-DD')


The order for the functions should be:
-NormalizeDate
-GetDayName
-GetMonthName
-GetDayNameF
-GetMonthNameF
-FormatDate
-FormatDateF
Open each one starting from the top, and simply click ok, so they are "loaded" properly, otherwise you might get errors trying to call them.