- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
They'll ship a date-handling library eventually, but 4D time being you have to roll your own.
Admin
Still better than JavaScripts date handling.
Admin
There's another wtf in there; it's only grabbing the last two digits of the year. The resulting string will be 24SEP25, so you have the added pleasure of wondering if it's September 24th of 2025, or September 25th of 2024.
Admin
Thank you so much for bringing up such a painful subject. While you're at it, why don't you give me a nice paper cut and pour lemon juice on it?
Admin
What I want to know is, as people were reading the code what language were they guessing this was written in?
Me, my best guess was that someone had decided to graft Perl and COBOL together.
Admin
Looks to be Pascal inspired to me from ":=" and "case of".
Admin
I asked ChatGPT before I even started to read the narrative and it got the right answer. the bit that really confused me was
C_STRING(2;$currentDay;$currentYear)
it looks like a function call, but a function call makes no sense in this context
Admin
I thought I knew about all the "platforms" out there, but no, somehow such a long-running product totally escaped me.
Addendum 2025-09-24 12:40: PS. Imagine looking for talent OR looking for a job as a 4D specialist. :)
Admin
I think what this is, is a variable declaration — or actually, two variable declarations in one, as they’re both to be strings of 2 characters (or bytes, or something anyway) in length. C_STRING declares the variable, the first parameter is the length, every parameter after that is a variable name that will be declared to fit this mould.
Admin
yep: "Based on the syntax and function names, the code snippet appears to be written in 4D, a programming language and integrated development environment (IDE) for building business applications.
[snip]
The code's purpose is to format a date, likely converting a date variable ($1) into a string representation like "JAN 25 2025" for a specific use case."
but clearly inspired partially by Pascal.
Admin
Interesting difference: While $currentMonth is a string of length 2 (2 bytes, 2 characters, 2 number symbols, 2 pieces, whatever), $month is declared as integer for the numerical comparing "Case of" block. Is there no way of accessing the "month property" for comparison directly? Also using the prefix "current" is a bit strange - the current date is derived from the C_DATE in $1, so it represents that exact date... it's all very strange...
Admin
Oh I remember having to develop a 4D webapp in my MA internship. With the added bonus that, in the French version of 4D, they also translated the programming language. PHP is absolutely a joy to work with compared to that abomination.
Admin
Going by how values are assigned to $currentDay, $month and $currentYear, I get the impression that C_DATE produces a dictionary or something similar, which you can ask for its Day, Month and Year properties. So I guess they could have done:
But perhaps decided it would be more readable to put the value into $month? Or, for all I know, getting Month of($1) takes appreciably longer than getting $month?
Admin
My first guess was: PHP and PLSQL had an unholy a deformed child. But given the "PHP support" of 4D, it might be more accurate that I would have liked.
Addendum 2025-09-25 05:17: My first guess was: PHP and PLSQL had an unholy and deformed child. But given the "PHP support" of 4D, it might be more accurate that I would have liked.
EDIT: Oh GODS the gui for editing posts in the worst fucking thing I've ever seen.
Addendum 2025-09-25 05:18: EDIT 2: And it doesn't even allow you to actually edit everything, just add an addendum. Now I look stupid.
Admin
I also thought it was COBOL at first, due to the strings specifying their length in the definitions.