@alpine:
my apologies, it is/was not my intention to criticize your input on the subject other than to point out the obvious 'mistake'.
You and me might be aware but TS does not seem to be, despite
wp's excellent explanation.
A simple test (and I kept the format strings relatively sane) shows that from 36 different datetime string formats the only thing you are able to determine is that it every individual part consist of the number/digits "01" (that test did not even include am/pm, day/month names (short or long) and or different separators).
The assumption with using 12 to determine between month and year says nothing about the year (or any other date/time part for that matter).
For all we know old(er) logs are analyzed, or the year is only displayed as 2 digits or that particular phone system is only up and running in the first half of the year or only handles/logs one single phone-call per month or per year (I have seen much stranger things than that in practice).
A deterministic approach can only succeed with enough data present that can be analyzed/tested against.
defined by telephony system from which it is derived.
and
Yes, of course, but what if date and time format in file will be different (e.g. from another telephony system)?
So TS should first determine how many different telephone systems there are (for use of his software), and if TS wishes to support them or not. Then determine how many different datetime formats should be dealt with/supported based on the logs of those phone systems.
You could try a deterministic approach for that with TryDateTimeToStr (though the documentation for TryDateTimeToStr is not very helpful and ambiguous imho).
TryStrToDateTime tries to convert the string S to a TDateTime date and time value, and stores the result in Value. The date must consist of 1 to three digits, separated by the DateSeparator character (1). If two numbers (!) are given, they are supposed to form the day and month of the current year. If only one number (!) is given, it is supposed to represent the day of the current month (This is not supported in Delphi). The time must consist of 1 to 4 digits, separated by the TimeSeparator character (2). If two numbers (!) are given, they are supposed to form the hour and minutes.
1/2: a bit strange use of the word digit, because in the date-string "21/12/2023" there are actually 8 digits and 3 numbers. No idea why there is supposedly a limit of 3 digits. Same for the time string, e.g. 11:22:33 (6 digits, 3 numbers, 2 time-separators).
But perhaps it is my lack of understanding the English language ?
The program/code of TS should not rely on any of the locale settings whatsoever and instead use the hard-coded format from the csv file (as determined by the phone system: datetime format string in = datetime format string out.
I've attached a small concept of using a deterministic approach using scandatetime (more so to avoid the use of formatsettings). Perhaps it is useful to someone.