FormatDate(Mask$, Date)
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
FormatDate(Mask$, Date)
The Mask$ for date formats is really minimal - would be good to have Day and Month names (full and abbreviated).
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: FormatDate(Mask$, Date)
In what language would you prefer the names? 

quidquid Latine dictum sit altum videtur
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: FormatDate(Mask$, Date)
erm, how about Mongolian?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: FormatDate(Mask$, Date)
For the mask %month, %day and for the result the userlanguage, should not a big problemfreak wrote:In what language would you prefer the names?

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: FormatDate(Mask$, Date)
GetLocaleInfo_(#LOCALE_USER_DEFAULT, ...)freak wrote:In what language would you prefer the names?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: FormatDate(Mask$, Date)
I don't like it, when applications in one language display shortcuts or dates in another language.
Re: FormatDate(Mask$, Date)
here a small example, to use a macro like FormatDate():
Code: Select all
Procedure.s FormatDateEx(Mask.s, Date.l)
Protected MonthName.s = Trim(PeekS(?FormatDateEx_MonthName+(Month(Date)-1)*8, 8))
Protected DayOfWeekName.s = Trim(PeekS(?FormatDateEx_DayOfWeekName+DayOfWeek(Date)*9, 9))
Mask = ReplaceString(Mask, "%month", MonthName, #PB_String_NoCase)
Mask = ReplaceString(Mask, "%day", DayOfWeekName, #PB_String_NoCase)
ProcedureReturn FormatDate(Mask, Date)
EndProcedure
Macro FormatDate(Mask, Date)
FormatDateEx(Mask, Date)
EndMacro
DataSection
FormatDateEx_DayOfWeekName:
Data.s "Sunday Monday Tuesday WednesdayThursday Friday Saturday "
FormatDateEx_MonthName:
Data.s "January FebruaryMarch April May June July August SeptemberOctober NovemberDecember"
EndDataSection
Debug FormatDate("%day, %dd. %month %yyyy", Date())
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: FormatDate(Mask$, Date)
It doesn't make sense to build anything and everything into PB. This concerns particularly stuff that we can easily write ourselves by using PB as it is.
Regards, Little John
Regards, Little John
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: FormatDate(Mask$, Date)
Yeah, you are right. Not having needed it before, I was just surprised to find the function to be so limited. When you only have numbers in dates, people can get confused because of the format. 05/04/2011 is the 5th of April in the UK and other countries, but it's the 4th of May in many others.Little John wrote:It doesn't make sense to build anything and everything into PB. This concerns particularly stuff that we can easily write ourselves by using PB as it is.
Regards, Little John
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: FormatDate(Mask$, Date)
Sure it does! Fred did it all the time in the past. It's only in the past few years that responding to user requests slowed down, immensely. There was a time when little requests like this one were honored very quickly, but the language was much younger back then, so I guess it had to grow.Little John wrote:It doesn't make sense to build anything and everything into PB.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: FormatDate(Mask$, Date)
I absolutely agree, and I'm aware of that problem.IdeasVacuum wrote:When you only have numbers in dates, people can get confused because of the format. 05/04/2011 is the 5th of April in the UK and other countries, but it's the 4th of May in many others.
It's just so easy to write a little function myself, that works exactly like I want. And someone else probably wants such a function to work a little differently, so s/he'll write a function that works exactly like s/he wants, etc. ...

Regards, Little John
Re: FormatDate(Mask$, Date)
Internationalization is one of the hardest things to get absolutely right. I really don't want to open that can of worms for such a small issue.
quidquid Latine dictum sit altum videtur