AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

FormatSettings for Dummies

Ein Thema von haentschman · begonnen am 12. Apr 2016 · letzter Beitrag vom 1. Mai 2019
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.429 Beiträge
 
Delphi 12 Athens
 
#1

AW: FormatSettings for Dummies

  Alt 12. Apr 2016, 15:56
Danke für deine Anteilnahme...

Antwort: Exakt gleich falsch.

PS: Auch der XX = Vormittags String Zusatz bei 12 Stundenanzeige wird in den FormatSettings nicht übernommen, die Strings dafür schon ... (Im DateTimePicker.Format ist es tt)

Es sieht danach aus als ob für
DateShortFormat, DateLongFormat, TimeShortFormat, TimeLongFormat Standardwerte zurückgegeben werden statt der Einstellungen. Alles Andere wird offensichtlich angepaßt.
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.196 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: FormatSettings for Dummies

  Alt 12. Apr 2016, 16:10
Also laut
http://qc.embarcadero.com/wc/qcmain.aspx?d=104942

kann man das für einen Fehler halten, das "/" sei allerdings ein "Meta-Character" für den DateSeparator und nicht als "/"-Zeichen zu verstehen.
  Mit Zitat antworten Zitat
Cashew

Registriert seit: 15. Mär 2017
24 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#3

AW: FormatSettings for Dummies

  Alt 30. Apr 2019, 07:23
Moin...

gestern bin ich auch über die Probleme mit den TFormatSettings gestolpert.

Was hat es den mit diesem "Meta-Character" auf sich? Den unten aufgeführten Link kann ich bei mir nicht (mehr ?) öffnen.

Also laut
http://qc.embarcadero.com/wc/qcmain.aspx?d=104942

kann man das für einen Fehler halten, das "/" sei allerdings ein "Meta-Character" für den DateSeparator und nicht als "/"-Zeichen zu verstehen.

Wenn ich das ganze aber richtig verstehe, dann bleibt einem nichts anders übrig, als die "falschen" Werte in den TFormatSettings zu korrigieren?
What goes arround, comes arround
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.220 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: FormatSettings for Dummies

  Alt 30. Apr 2019, 07:46
qc.embarcadero.com ist das alte BugTracking-System das mittlerweile abgschaltet wurde.
Nur noch quality.embarcadero.com ist die Einzige Quelle für solche Infos.
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
Cashew

Registriert seit: 15. Mär 2017
24 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#5

AW: FormatSettings for Dummies

  Alt 30. Apr 2019, 09:00
Vielen Dank für die Info.

Gibt es dann die erwähnten Erklärungen zum "Meta Character" irgendwo noch zum nachlesen? Oder kann mir jemand vielleicht so kurz sagen was damals die Erklärung von Embarcadero dazu war?
What goes arround, comes arround
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.629 Beiträge
 
Delphi 12 Athens
 
#6

AW: FormatSettings for Dummies

  Alt 30. Apr 2019, 09:56
Ohne diesen alten Thread jetzt nochmal komplett durchzulesen: Die Funktion FormatDateTime z.B. erwartet als Datumstrenner ein "/", weil das im Code fest so hinterlegt ist. Lässt man dort den Formatstring leer, wird TFormatSettings.ShortDateFormat verwendet.

Demnach sollten Datums-Formatstrings immer ein "/" als Datumstrenner verwenden, der dann in den aktuellen TFormatSettings.DateSeparator umgewandelt wird. Ich sehe da jetzt nichts falsches daran, wenn Delphi die Einträge für die vordefinierten Datumsformate entsprechend anpasst. Das schließt natürlich nicht aus, daß jemand seine Programme so schreibt, daß dieses Verhalten einen Fehler auslöst. Das ist dann aber eher ein Problem des betreffenden Programmierers, der hier eine andere Erwartungshaltung hat, und kein Fehler in der RTL.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Cashew

Registriert seit: 15. Mär 2017
24 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#7

AW: FormatSettings for Dummies

  Alt 30. Apr 2019, 16:34
Ohne diesen alten Thread jetzt nochmal komplett durchzulesen: Die Funktion FormatDateTime z.B. erwartet als Datumstrenner ein "/", weil das im Code fest so hinterlegt ist. Lässt man dort den Formatstring leer, wird TFormatSettings.ShortDateFormat verwendet.
Danke für die Info, war mir so noch nicht bewusst...
What goes arround, comes arround
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.338 Beiträge
 
Delphi 12 Athens
 
#8

AW: FormatSettings for Dummies

  Alt 12. Apr 2016, 16:13
Das "/" und ":" in den Date-/Time-Strings wird durch die Werte von DateSeparator und TimeSeparator ersetzt, in den Formatfunktionen.

Will man das nicht, dann muß man die in " einfassen.
'hh":"mm":"ss' macht immer ":", egal was in TimeSeparator drin steht.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.429 Beiträge
 
Delphi 12 Athens
 
#9

AW: FormatSettings for Dummies

  Alt 12. Apr 2016, 18:49
Ok, dann stell ich mich mal blöd...

1. Warum kommt hier Label.Caption := FormatDateTime(Now, FormatSettings.ShortDateFormat) 12/04/2016 statt 12.04.2016 ?
-> weil die FormatStrings nicht "kompatibel" sind.
2. Warum steht im ShortTimeFormat etc. immer hh statt HH wie ausgewählt?
-> FormatDateTime(Now, FormatSettings.ShortTimeFormat) immer 07:49 statt 19:49 wie ausgewählt?
3. Warum werden beim Auswählen des englischen Formates zwar die Strings für Vormittag / Nachmittag in FormatSettings eingetragen aber kein Platzhalter dafür?
-> Wie soll FormatDatetime wissen ob Vormittag oder Nachmittag?

Mit FormatDateTime geht es nicht. Mit DateTimeToString http://docwiki.embarcadero.com/Libra...teTimeToString geht die Ersetzung des / im Datum.
Delphi-Quellcode:
DateTimeToString(Result,
                 FormatSettings.ShortDateFormat + ' - ' + FormatSettings.ShortTimeFormat,
                 Now);
ergibt deutsch 14.04.2016 20:48 und englisch 14/04/2016 20:48 je nach Datumeinstellung
...egal welche Einstellungen für den Zeitanteil gewählt werden, der Zeitanteil ist immer gleich. (siehe Punkt 2 + 3)

Geändert von haentschman (12. Apr 2016 um 20:07 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von baumina
baumina

Registriert seit: 5. Mai 2008
Ort: Oberschwaben
1.275 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: FormatSettings for Dummies

  Alt 13. Apr 2016, 06:14
Wenn ich einen Blick in die SysUtils werfe, sehe ich dass es 'HH' als Formatierung nicht gibt. Es gibt nur 'hh', wenn man keine 24-Stundenanzeige will, wird das über am/pm geregelt.

Zitat:
{ FormatDateTime formats the date-and-time value given by DateTime using the
format given by Format. The following format specifiers are supported:

c Displays the date using the format given by the ShortDateFormat
global variable, followed by the time using the format given by
the LongTimeFormat global variable. The time is not displayed if
the fractional part of the DateTime value is zero.

d Displays the day as a number without a leading zero (1-31).

dd Displays the day as a number with a leading zero (01-31).

ddd Displays the day as an abbreviation (Sun-Sat) using the strings
given by the ShortDayNames global variable.

dddd Displays the day as a full name (Sunday-Saturday) using the strings
given by the LongDayNames global variable.

ddddd Displays the date using the format given by the ShortDateFormat
global variable.

dddddd Displays the date using the format given by the LongDateFormat
global variable.

g Displays the period/era as an abbreviation (Japanese and
Taiwanese locales only).

gg Displays the period/era as a full name.

e Displays the year in the current period/era as a number without
a leading zero (Japanese, Korean and Taiwanese locales only).

ee Displays the year in the current period/era as a number with
a leading zero (Japanese, Korean and Taiwanese locales only).

m Displays the month as a number without a leading zero (1-12). If
the m specifier immediately follows an h or hh specifier, the
minute rather than the month is displayed.

mm Displays the month as a number with a leading zero (01-12). If
the mm specifier immediately follows an h or hh specifier, the
minute rather than the month is displayed.

mmm Displays the month as an abbreviation (Jan-Dec) using the strings
given by the ShortMonthNames global variable.

mmmm Displays the month as a full name (January-December) using the
strings given by the LongMonthNames global variable.

yy Displays the year as a two-digit number (00-99).

yyyy Displays the year as a four-digit number (0000-9999).

h Displays the hour without a leading zero (0-23).

hh Displays the hour with a leading zero (00-23).

n Displays the minute without a leading zero (0-59).

nn Displays the minute with a leading zero (00-59).

s Displays the second without a leading zero (0-59).

ss Displays the second with a leading zero (00-59).

z Displays the millisecond without a leading zero (0-999).

zzz Displays the millisecond with a leading zero (000-999).

t Displays the time using the format given by the ShortTimeFormat
global variable.

tt Displays the time using the format given by the LongTimeFormat
global variable.

am/pm Uses the 12-hour clock for the preceding h or hh specifier, and
displays 'am' for any hour before noon, and 'pm' for any hour
after noon. The am/pm specifier can use lower, upper, or mixed
case, and the result is displayed accordingly.

a/p Uses the 12-hour clock for the preceding h or hh specifier, and
displays 'a' for any hour before noon, and 'p' for any hour after
noon. The a/p specifier can use lower, upper, or mixed case, and
the result is displayed accordingly.

ampm Uses the 12-hour clock for the preceding h or hh specifier, and
displays the contents of the TimeAMString global variable for any
hour before noon, and the contents of the TimePMString global
variable for any hour after noon.

/ Displays the date separator character given by the DateSeparator
global variable.

: Displays the time separator character given by the TimeSeparator
global variable.

'xx' Characters enclosed in single or double quotes are displayed as-is,
"xx" and do not affect formatting.

Format specifiers may be written in upper case as well as in lower case
letters--both produce the same result.

If the string given by the Format parameter is empty, the date and time
value is formatted as if a 'c' format specifier had been given.

The following example:

S := FormatDateTime('"The meeting is on" dddd, mmmm d, yyyy, ' +
'"at" hh:mm AM/PM', StrToDateTime('2/15/95 10:30am'));

assigns 'The meeting is on Wednesday, February 15, 1995 at 10:30 AM' to
the string variable S. }
Hinter dir gehts abwärts und vor dir steil bergauf ! (Wolfgang Ambros)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz