Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   WMI Datetime 00000000000.00000+000 (https://www.delphipraxis.net/138506-wmi-datetime-00000000000-00000-000-a.html)

Jackie1983 11. Aug 2009 16:48


WMI Datetime 00000000000.00000+000
 
Servus,

bekomme oben die Zahlen als Datetime.
Nur wie kann ich das Zeitformat ins Delphi Zeitformat umwandeln.

gruß

Klaus01 11. Aug 2009 19:19

Re: WMI Datetime 00000000000.00000+000
 
.. schaut es nicht aus wie ein TDateTime Format mit angehängter Abweichung von GMT?

Wobei man aus 00000000000.00000+000 wenig zurückrechnen kann.

Grüße
Klaus

Jackie1983 12. Aug 2009 09:27

Re: WMI Datetime 00000000000.00000+000
 
mich hat nur das +000 dahinter gestört. Habe jetzt gesehen das es die Zeitzone ist.
Habe die Zahlen nur durch 0 ersetzt.
20090811173139.232000+120

gruß

Jackie1983 12. Aug 2009 12:03

Re: WMI Datetime 00000000000.00000+000
 
Gibt es eventuell eine Methode um das umrechnen zulassen?
Weil wenn ich die +120 abschneide und versuche ein DateTime draus zu machen,
bekomme ich einen Fehler.

himitsu 12. Aug 2009 12:21

Re: WMI Datetime 00000000000.00000+000
 
Zitat:

Zitat von Jackie1983
Weil wenn ich die +120 abschneide und versuche ein DateTime draus zu machen,
bekomme ich einen Fehler.

weil es kein TDateTime-Wert ist?

TDateTime ist ja eine Delphi- oder besser Pascaleigene Angelegenheit (Tage seit Beginn der Pascal-Epoche)

dieses ist ein anderer Wert, aber warum es zur exception kommt ... du hast ja bestimmt ein deutsches Windows und da ist das "," als Dezimalseperator definiert ... hier ist es der "." ... du mußt also bei der Umwandlung den Punkt beachten

Code:
00000000000.00000+000
^ Tage seit einem bestimmten Datum (weiß jetzt aber grad nicht seit welchem)
            ^ Anteil des letzen Tages (wie bei TDateTime)
                  ^ Zeitzonenverschiebung in Minuten (UTC)
praktisch kannst du ...
- Zeitzone abschneiden, also ab "+" oder "-"
- StrToFloat (oder ähnliches, wegen dem Punkt ... z.B. S := StringReplace(S, '.', DecimalSeparator, []); )
- die Differenz zwischen WMI-Datetime und Delphi-TDateTime dazurechnen
- eventuell noch die Zeitzone dazurechnen (D := D + Zone/60/24)
- und Ergebnis kann nun als TDateTime angesehn werden

Klaus01 12. Aug 2009 13:18

Re: WMI Datetime 00000000000.00000+000
 
Wenn das nun ein "richtiges" Beispiel ist:
Zitat:

Zitat von Jackie1983
20090811173139.232000+120

Ist es dann nicht
Jahr: 2009
Monat: 08
Tag: 11
Stunde: 17
Minute: 31
Sekunden: 39

Hinter dem Punkt vielleicht Millisekunden
+ Zeitzone.

Wenn Du es in TDateTime umkodieren willst
bastel Dir einen String daraus und übergib
diesen der StrToDateTime Routine.

Zitat:

Unit
SysUtils

Syntax


[Delphi] function StrToDateTime(const S: string): TDateTime; overload;



[Delphi] function StrToDateTime(const S: string; var FormatSettings: TFormatSettings): TDateTime; overload;


Description
Call StrToDateTime to parse a string that specifies a date and time value. If S does not contain a valid date, StrToDateTime raises an EConvertError exception.
The S parameter must use the current locale's date/time format. In the US, this is commonly MM/DD/YY HH:MM:SS format. Specifying AM or PM as part of the time is optional, as are the seconds. Use 24-hour time (7:45 PM is entered as 19:45, for example) if AM or PM is not specified.
Year values between 0 and 99 are converted using the TwoDigitYearCenturyWindow. This value is stored either in a global variable (first form) or as a field in the FormatSettings parameter (second form) See "Currency and Date -Time Formatting Variables" for more information.
The first form of StrToDateTime is not thread-safe, because it uses localization information contained in global variables. The second form of StrToDateTime, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of StrToDateTime, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings .

Grüße
Klaus


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz