Pages: 1
Author Topic: date_date_string change format  (48,337 Views)
Offline (Unknown gender) Rory

Member
Joined: Sep 2014
Posts: 1
View profile
Posted on: August 28, 2015, 09:39:41 PM
So in Enigma by default to date_date_string() function returns the date in the MM/DD/YYYY format. How can I change this to the DD/MM/YYYY format?
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #1 Posted on: August 28, 2015, 11:06:57 PM
The date_date_string() should print locale dependent. So if you are outside US it should be DD/MM/YYYY.

But you can use date_datetime_stringf() to format it like you want. The formats can actually be found here: http://www.cplusplus.com/reference/ctime/strftime/, as the function is not currently documented in ENIGMA wiki.
So if you want DD/MM/YYYY it would be like this:
date_datetime_stringf(data, "%d/%m/%y");
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #2 Posted on: September 02, 2015, 04:51:34 AM
Please follow Harri's advice, but also he is incorrect about these functions not being documented on the Wiki because they are (I documented every single one).
http://enigma-dev.org/docs/Wiki/Date_and_Time_Functions

On a side note Harri, I am not sure if that function is a great idea because what if we do ever support a different language, shouldn't we need to define our own date/time formatting? Don't stress about it, just something I want to call your attention to. At the same time it doesn't matter because we could likely just add the C++ standard date/time formatting to the other programming languages and adopt it as our standard.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #3 Posted on: September 02, 2015, 06:23:48 PM
QuotePlease follow Harri's advice, but also he is incorrect about these functions not being documented on the Wiki because they are (I documented every single one).
Except the one I posted. :D You documented GM functions and date_datetime_stringf() is not in GM.

QuoteOn a side note Harri, I am not sure if that function is a great idea because what if we do ever support a different language, shouldn't we need to define our own date/time formatting? Don't stress about it, just something I want to call your attention to. At the same time it doesn't matter because we could likely just add the C++ standard date/time formatting to the other programming languages and adopt it as our standard.
What exactly do you propose? I don't know many ways to format time and this seems like a standard one. There is the .NET and Java version like "DD/MM/YYYY" which is actually a formatting string.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #4 Posted on: September 02, 2015, 08:25:36 PM
Yeah but still I documented it to.

And I'm not suggesting anything, just that we create our own now or stick with the C++ one. Like if we ever add JS as a scripting language like Unity that we wrap the method to format it the same way.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #5 Posted on: September 03, 2015, 11:14:51 AM
QuoteYeah but still I documented it to.
I only see date_datetime_string, but no date_datetime_stringf. So I don't see how it is documented. :D
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #6 Posted on: September 03, 2015, 01:19:08 PM
Ok that's weird, figured I would have documented that one, it's in fact, the only one I did not. I honestly have no idea anymore lol.
Pages: 1