<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Datumstring in Double umwandeln]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>ich möchte einen String, welcher eine Datum/Zeit Angabe darstellt in ein Double Wert umwandeln.</p>
<p>z.B. &quot;20.10.2016 13:10:22&quot;</p>
<p>Normalerweise benutze ich die Funktion StrToDateTime().<br />
Das Ergebnis davon weise ich dann einer Double Variablen zu.</p>
<p>Problem:<br />
Wird im Windows Betriebsystem das Datumsformat in den Einstellungen geändert, so erhalte ich beim Aufruf der Funktion StrToDateTime() eine Fehlermeldung,<br />
dass &quot;20.10.2016 13:10:22&quot; keine gütige Datums-/Zeitangabe sei.</p>
<p>Hat jemand eine alternative zur Funktion StrToDateTime?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/340242/datumstring-in-double-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 08:49:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/340242.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Oct 2016 14:19:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Thu, 27 Oct 2016 14:19:50 GMT]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>ich möchte einen String, welcher eine Datum/Zeit Angabe darstellt in ein Double Wert umwandeln.</p>
<p>z.B. &quot;20.10.2016 13:10:22&quot;</p>
<p>Normalerweise benutze ich die Funktion StrToDateTime().<br />
Das Ergebnis davon weise ich dann einer Double Variablen zu.</p>
<p>Problem:<br />
Wird im Windows Betriebsystem das Datumsformat in den Einstellungen geändert, so erhalte ich beim Aufruf der Funktion StrToDateTime() eine Fehlermeldung,<br />
dass &quot;20.10.2016 13:10:22&quot; keine gütige Datums-/Zeitangabe sei.</p>
<p>Hat jemand eine alternative zur Funktion StrToDateTime?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513089</guid><dc:creator><![CDATA[mr_crabs]]></dc:creator><pubDate>Thu, 27 Oct 2016 14:19:50 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Thu, 27 Oct 2016 14:32:18 GMT]]></title><description><![CDATA[<p>Ich weiß nicht was du verwendest aber ich habe das hier gefunden.</p>
<p><a href="http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate3/EN/html/delphivclwin32/SysUtils_GetLocaleFormatSettings.html" rel="nofollow">http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate3/EN/html/delphivclwin32/SysUtils_GetLocaleFormatSettings.html</a></p>
<p>damit die settings abrufen und bei strtodatetime als 2. parameter hinzufügen.</p>
<p>Hab das aber nicht getestet, da ich diese funktionen nicht kenne.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513091</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 27 Oct 2016 14:32:18 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Thu, 27 Oct 2016 15:14:28 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>mr_crabs schrieb:</p>
<blockquote>
<p>Hat jemand eine alternative zur Funktion StrToDateTime?</p>
</blockquote>
<p>Ja - Standard C++!</p>
<p>Da gibt es den Manipulator <a href="http://en.cppreference.com/w/cpp/io/manip/get_time" rel="nofollow">std::get_time</a>.<br />
Und wenn Du aus der Zeitinformation unbedingt einen double machen möchtest, so geht das auch:</p>
<pre><code>#include &lt;ctime&gt;    // std::tm, mktime
#include &lt;chrono&gt;   // chrono::duration
#include &lt;iomanip&gt;  // std::put_time, get_time
#include &lt;iostream&gt;
#include &lt;sstream&gt;

typedef std::chrono::system_clock Clock;

int main()
{
    using namespace std;
    istringstream buf( &quot;20.10.2016 13:10:22&quot; );
    tm aTime;
    if( buf &gt;&gt; get_time( &amp;aTime, &quot;%d.%m.%Y %H:%M:%S&quot; ) )
    {
        auto zeitpunkt = Clock::from_time_t( mktime( &amp;aTime ) );
        typedef chrono::duration&lt; double &gt; Sekunden;
        cout &lt;&lt; chrono::duration_cast&lt; Sekunden &gt;( zeitpunkt.time_since_epoch() ).count() &lt;&lt; &quot;s&quot; &lt;&lt; endl;
    }
    else
        cerr &lt;&lt; &quot;Format Fehler&quot; &lt;&lt; endl;
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2513098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513098</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 27 Oct 2016 15:14:28 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Thu, 27 Oct 2016 16:18:34 GMT]]></title><description><![CDATA[<p>Werner Salomon schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>mr_crabs schrieb:</p>
<blockquote>
<p>Hat jemand eine alternative zur Funktion StrToDateTime?</p>
</blockquote>
<p>Ja - Standard C++!</p>
<p>Da gibt es den Manipulator <a href="http://en.cppreference.com/w/cpp/io/manip/get_time" rel="nofollow">std::get_time</a>.<br />
Und wenn Du aus der Zeitinformation unbedingt einen double machen möchtest, so geht das auch:</p>
<pre><code>#include &lt;ctime&gt;    // std::tm, mktime
#include &lt;chrono&gt;   // chrono::duration
#include &lt;iomanip&gt;  // std::put_time, get_time
#include &lt;iostream&gt;
#include &lt;sstream&gt;

typedef std::chrono::system_clock Clock;

int main()
{
    using namespace std;
    istringstream buf( &quot;20.10.2016 13:10:22&quot; );
    tm aTime;
    if( buf &gt;&gt; get_time( &amp;aTime, &quot;%d.%m.%Y %H:%M:%S&quot; ) )
    {
        auto zeitpunkt = Clock::from_time_t( mktime( &amp;aTime ) );
        typedef chrono::duration&lt; double &gt; Sekunden;
        cout &lt;&lt; chrono::duration_cast&lt; Sekunden &gt;( zeitpunkt.time_since_epoch() ).count() &lt;&lt; &quot;s&quot; &lt;&lt; endl;
    }
    else
        cerr &lt;&lt; &quot;Format Fehler&quot; &lt;&lt; endl;
    return 0;
}
</code></pre>
</blockquote>
<p>Der Code gefällt mir! Eine kleine Anmerkung aber noch: <code>duration_cast</code> ist hier überflüssig, denn <code>duration&lt;floating_point_type&gt;</code> kann implizit aus <code>duration&lt;integer_type&gt;</code> erstellt werden. Als Faustregel: <code>duration_cast</code> nur verwenden, wenn die Konvertierung verlustbehaftet ist, z.B. <code>float</code> -&gt; <code>int</code> .<br />
So würde ich Zeile 18 schreiben:</p>
<pre><code>cout &lt;&lt; Sekunden{zeitpunkt.time_since_epoch()}.count() &lt;&lt; &quot;s&quot; &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2513105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513105</guid><dc:creator><![CDATA[Biolunar]]></dc:creator><pubDate>Thu, 27 Oct 2016 16:18:34 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Sat, 29 Oct 2016 07:34:47 GMT]]></title><description><![CDATA[<p>hi leute</p>
<p>gibts sowas aehnliches wie prototype fuer template parameter ?<br />
also welche memberfunktionen eine klasse haben muss damit sie als template parameter akzeptiert werden kann ?<br />
aehnlich wie pure-virtual classes zur laufzeit.</p>
<p>zur veranschaulichung kurzer code:</p>
<pre><code>struct class_prototype
{
   auto size(void) const -&gt; int;
   auto convert(int value) const int;
   auto name(void) const -&gt; const char*;
};

struct korrekter_prototyp
{
   auto size(void) const -&gt; int;
   auto convert(int value) const int;
   auto name(void) const -&gt; const char*;
};

struct fehlerhafter_prototyp
{
   auto size(void) const -&gt; int;
   auto convert(int value) const int;
};

template&lt;class T&gt;
struct test_class
{
   T obj;
};

...
test_class&lt;korrekter_prototyp&gt; test1; // ok
test_class&lt;fehlerhafter_prototyp&gt; test2; // error
</code></pre>
<p>gibt es da eine möglichkeit fuer sowas ?</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513297</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513297</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Sat, 29 Oct 2016 07:34:47 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Sat, 29 Oct 2016 08:10:15 GMT]]></title><description><![CDATA[<p>Das sollte mit den <em>Concepts</em> in kommeden Standards möglich sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513300</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 29 Oct 2016 08:10:15 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Sat, 29 Oct 2016 08:58:01 GMT]]></title><description><![CDATA[<p>Man kann soetwas zumindest emulieren:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;type_traits&gt;

namespace detail {
	struct any {
		template &lt;typename T&gt; any(T) { }
	};
}

#define GENERATE_HAS_MEM_FUN(fun)\
template &lt;typename, typename T, typename...&gt;\
class has_mem_fun_##fun {\
	static_assert(std::integral_constant&lt;T, false&gt;::value, &quot;has_mem_fun_##fun needs function type as second template parameter&quot;);\
};\
template &lt;typename T, typename ReturnType, typename ...Args, typename ...TemplateArgs&gt;\
class has_mem_fun_##fun&lt;T, ReturnType(Args...), TemplateArgs...&gt; {\
	template &lt;typename U&gt;\
	static typename std::is_same&lt;decltype(std::declval&lt;U&gt;().fun(std::declval&lt;Args&gt;()...)), ReturnType&gt;::type\
		test(int);\
\
	template &lt;typename U&gt;\
	static typename std::is_same&lt;decltype(std::declval&lt;U&gt;().template fun&lt;TemplateArgs...&gt;(std::declval&lt;Args&gt;()...)), ReturnType&gt;::type\
		test(any);\
\
	template &lt;typename&gt;\
	static std::false_type test(...);\
public:\
	static constexpr bool value = decltype(test&lt;T&gt;(0))::value;\
};

#define GENERATE_HAS_MEMBER(mem)\
template &lt;typename T&gt;\
struct has_member_##mem##_impl {\
	template &lt;typename U&gt; static std::true_type overload(decltype(&amp;U::mem));\
	template &lt;typename&gt; static std::false_type overload(...);\
	\
	static constexpr bool result = decltype(overload&lt;T&gt;(nullptr))::value;\
};\
template &lt;typename T&gt;\
struct has_member_##mem : public std::integral_constant&lt;bool, has_member_##mem##_impl&lt;T&gt;::result&gt; { };

#define GENERATE_HAS_TYPE(type)\
template &lt;typename T&gt;\
struct has_type_##type##_impl {\
	template &lt;typename U&gt;\
	static std::true_type overload(typename U::type*);\
	template &lt;typename&gt;\
	static std::false_type overload(...);\
\
	static constexpr bool result = decltype(overload&lt;T&gt;(nullptr))::value;\
};\
template &lt;typename T&gt;\
struct has_type_##type : public std::integral_constant&lt;bool, has_type_##type##_impl&lt;T&gt;::result&gt; { };

struct foo {
	foo() = default;
	foo(const foo&amp;) = delete;
	foo(foo&amp;&amp;) = default;
	foo&amp; operator =(const foo&amp;) = delete;
	foo&amp; operator =(foo&amp;&amp;) = default;
	~foo() = default;

	using myType = int;
	char myMem;
	int bar(double, std::string&amp;) { }
};

namespace detail {
	GENERATE_HAS_MEMBER(myMem);
	GENERATE_HAS_TYPE(myType);
	GENERATE_HAS_MEM_FUN(bar);
}

template &lt;typename T&gt;
using is_foo_compatible = std::conjunction&lt;std::is_default_constructible&lt;T&gt;,
										   std::negation&lt;std::is_copy_constructible&lt;T&gt;&gt;,
										   std::negation&lt;std::is_copy_assignable&lt;T&gt;&gt;,
										   std::negation&lt;std::is_final&lt;T&gt;&gt;,
										   std::is_destructible&lt;T&gt;,
										   detail::has_member_myMem&lt;T&gt;,
										   detail::has_type_myType&lt;T&gt;,
										   detail::has_mem_fun_bar&lt;T, int(double, std::string&amp;)&gt;
										  &gt;;
int main() {
	std::cout &lt;&lt; std::boolalpha &lt;&lt; is_foo_compatible&lt;foo&gt;::value &lt;&lt; '\n';
}
</code></pre>
<p>Der Code hat aber einige Schwächen. Er kann z.B. in Memberfunktionen nicht zwischen Referenzen und Nicht-Referenzen unterscheiden, const ignoriert er dabei auch. Zusätzlich ignoriert er, ob eine Memberfunktion virtuell ist oder nicht. Sofern du konstante Member-Funktionen erzwingen willst, muss du entsprechend <code>detail::has_mem_fun_bar&lt;const T, int(double, std::string&amp;) const&gt;</code> schreiben. Falls du kein C++17 hast, musst du std::conjunction und std::negation selber programmieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513305</guid><dc:creator><![CDATA[Jodocus]]></dc:creator><pubDate>Sat, 29 Oct 2016 08:58:01 GMT</pubDate></item><item><title><![CDATA[Reply to Datumstring in Double umwandeln on Sat, 29 Oct 2016 09:12:14 GMT]]></title><description><![CDATA[<p>lustig. eigendlich haette das ein eigener beitrag werden sollen. hab scheinbar ins falsche fenster geschrieben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2513307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2513307</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Sat, 29 Oct 2016 09:12:14 GMT</pubDate></item></channel></rss>