<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : ShiftDate_Month</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Calendar : ShiftDate_Month]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Tue, 19 May 2026 21:59:32 +0000</pubDate>
  <lastBuildDate>Sat, 28 Feb 2009 17:42:56 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=13522</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[ShiftDate_Month : The formula is very simple:   AFX_INLINE...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46017&amp;title=shiftdate-month#46017</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13522<br /><strong>Posted:</strong> 28 February 2009 at 5:42pm<br /><br />The formula is very simple: <DIV><FONT size=2><FONT size=2><P>AFX_INLINE BOOL CXTPCalendarUtils::ShiftDate_Month(COleDateTime &amp;refDate, </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nMonthCount)</P><P>{</P><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nYearOld = refDate.GetYear();</P><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nMonthOld = refDate.GetMonth();</P><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nYearNew = nYearOld + (-12 + nMonthOld + nMonthCount) / 12;</P><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nMonthCalc = nMonthOld + nMonthCount - 1;</P><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (nMonthCalc &lt; 0)</P><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><P>nMonthCalc = 12 * (-nMonthCalc) + nMonthCalc;</P></BLOCKQUOTE><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nMonthNew = 1 + nMonthCalc % 12;</P><P></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> COleDateTime::valid == refDate.SetDate(nYearNew, nMonthNew, 1);</P></BLOCKQUOTE><P>}</P><DIV></DIV>I already update SVN. Thank you!</FONT></FONT></DIV>]]>
   </description>
   <pubDate>Sat, 28 Feb 2009 17:42:56 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46017&amp;title=shiftdate-month#46017</guid>
  </item> 
  <item>
   <title><![CDATA[ShiftDate_Month : No - I checked SVN - this version...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46014&amp;title=shiftdate-month#46014</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13522<br /><strong>Posted:</strong> 28 February 2009 at 2:18pm<br /><br /><DIV>No - I checked SVN - this version identical to Nov 2008 version (Rev 12.1)</DIV><DIV>I can cofirm the bug you found.</DIV><DIV>this is old code:</DIV><P dir=ltr style="MARGIN-RIGHT: 0px">AFX_INLINE&nbsp; BOOL CXTPCalendarUtils::ShiftDate_Month(COleDateTime &amp;refDate, int nMonthCount)<BR>{<BR>&nbsp;SYSTEMTIME sysDate;<BR>&nbsp;if (!GETASSYSTEMTIME_DT(refDate, sysDate))<BR>&nbsp;&nbsp;return FALSE;</P><P dir=ltr style="MARGIN-RIGHT: 0px">&nbsp;int nYearNew = sysDate.wYear + nMonthCount / 12;<BR>&nbsp;int nMonthNew = sysDate.wMonth + nMonthCount % 12;</P><P dir=ltr style="MARGIN-RIGHT: 0px">&nbsp;if (nMonthNew &gt; 12)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; nMonthNew -= 12 * (nMonthCount / abs(nMonthCount));<BR>&nbsp;&nbsp; &nbsp;&nbsp;nYearNew++;<BR>&nbsp;}<BR>&nbsp;else if (nMonthNew &lt;= 0)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; nYearNew--;<BR>&nbsp;&nbsp;&nbsp;&nbsp; nMonthNew += 12;</P><P dir=ltr style="MARGIN-RIGHT: 0px">&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(nMonthNew &gt;= 1 &amp;&amp; nMonthNew &lt;= 12);<BR>&nbsp;}</P><P>&nbsp;return COleDateTime::valid == refDate.SetDate(nYearNew, nMonthNew, 1);</P><P>}</P><DIV>Unfortunately % operator in MS doing not proper modulo arithm - in math it suppose to give you positive result or nul - in MS - NOT:</DIV><DIV><FONT size=2><P>COleDateTime refDate(2000,1,1,0,0,0);</P><P>SYSTEMTIME sysDate; </P><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (GETASSYSTEMTIME_DT(refDate, sysDate))</P><P>{</P><P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nYearNew, nMonthNew, nMonthCount;</P><P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (nMonthCount = -20; nMonthCount &lt; 20; nMonthCount++)</P><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp; //modulo operation debug:</DIV><DIV>nYearNew = sysDate.wYear + (sysDate.wMonth + nMonthCount) / 12;</DIV><P>nMonthNew = 1 + ((int) (sysDate.wMonth) + nMonthCount - 1) % 12;</P><DIV>===&gt; it give nMonthNew = -7 in first loop step!</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp; //this is old code debug:</DIV><FONT size=2><P>nYearNew = sysDate.wYear + nMonthCount / 12; </P><P>nMonthNew = sysDate.wMonth + nMonthCount % 12; </P><P>nMonthNew -= 12 * (nMonthCount / abs(nMonthCount)); </P><P>nYearNew += nMonthCount / abs(nMonthCount); </P><P>ASSERT(nMonthNew &gt;= 1 &amp;&amp; nMonthNew &lt;= 12);</P><DIV></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this code give ASSERTION with nMonthNew = 13</DIV><DIV>}</FONT></DIV></FONT></DIV>]]>
   </description>
   <pubDate>Sat, 28 Feb 2009 14:18:43 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46014&amp;title=shiftdate-month#46014</guid>
  </item> 
  <item>
   <title><![CDATA[ShiftDate_Month :     mdoubson wrote:Btw - n...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46011&amp;title=shiftdate-month#46011</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4605">zitz</a><br /><strong>Subject:</strong> 13522<br /><strong>Posted:</strong> 28 February 2009 at 1:14pm<br /><br /><table width="99%"><tr><td class="BBquote"><img src="forum_images/quote_box.png" title="Originally posted by mdoubson" alt="Originally posted by mdoubson" style="vertical-align: text-bottom;" /> <strong>mdoubson wrote:</strong><br /><br />Btw - n / abs(n) can also be -1 and compiler shoud understand it.</td></tr></table><br>No, it can't. If nMountCount &lt; 0 then <br><pre>if (nMonthNew &gt; 12) &lt;---- FALSE</pre>I think it was without "if" in former times, for example<br><pre> int nYearNew = sysDate.wYear + nMonthCount / 12;<br> int nMonthNew = sysDate.wMonth + nMonthCount % 12;<br>&nbsp;nMonthNew -= 12 * (nMonthCount / abs(nMonthCount));<br>&nbsp;nYearNew += nMonthCount / abs(nMonthCount);<br> ASSERT(nMonthNew &gt;= 1 &amp;&amp; nMonthNew &lt;= 12);<br></pre>and if nMountCount == 0 --&gt; crash<br>]]>
   </description>
   <pubDate>Sat, 28 Feb 2009 13:14:53 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46011&amp;title=shiftdate-month#46011</guid>
  </item> 
  <item>
   <title><![CDATA[ShiftDate_Month : I will check this - sorry - old...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46004&amp;title=shiftdate-month#46004</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13522<br /><strong>Posted:</strong> 28 February 2009 at 10:19am<br /><br />I will check this - sorry - old strange class - i already fixed here serious bugs recently. But&nbsp;there was no complains on this function.<DIV>&nbsp;</DIV><DIV>Btw - n / abs(n) can also be -1 and compiler shoud understand it.</DIV>]]>
   </description>
   <pubDate>Sat, 28 Feb 2009 10:19:18 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=46004&amp;title=shiftdate-month#46004</guid>
  </item> 
  <item>
   <title><![CDATA[ShiftDate_Month : Hello. I use Xtreme ToolkitPro...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=45996&amp;title=shiftdate-month#45996</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4605">zitz</a><br /><strong>Subject:</strong> 13522<br /><strong>Posted:</strong> 28 February 2009 at 2:30am<br /><br />Hello. I use Xtreme ToolkitPro v13.0.0<br><br><table width="99%"><tr><td><pre class="BBcode">AFX_INLINE BOOL CXTPCalendarUtils::ShiftDate_Month(COleDateTime &amp;refDate, int nMonthCount)<br>{<br>&nbsp;&nbsp;&nbsp; SYSTEMTIME sysDate;<br>&nbsp;&nbsp;&nbsp; if (!GETASSYSTEMTIME_DT(refDate, sysDate))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br><br>&nbsp;&nbsp;&nbsp; int nYearNew = sysDate.wYear + nMonthCount / 12;<br>&nbsp;&nbsp;&nbsp; int nMonthNew = sysDate.wMonth + nMonthCount % 12;<br><br>&nbsp;&nbsp;&nbsp; if (nMonthNew &gt; 12)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nMonthNew -= 12 * (nMonthCount / abs(nMonthCount));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nYearNew++;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else if (nMonthNew &lt;= 0)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nYearNew--;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nMonthNew += 12;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ASSERT(nMonthNew &gt;= 1 &amp;&amp; nMonthNew &lt;= 12);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; return COleDateTime::valid == refDate.SetDate(nYearNew, nMonthNew, 1);<br>}</pre></td></tr></table><br>Function works wrong at release (Visual C++ 6.0) for nMonthCount = -1, I think because inline<br><br>For what?<br>nMonthNew -= 12 * <b>(nMonthCount / abs(nMonthCount))</b>;<br>It is unnecessary here i think.<br><b>nMonthCount / abs(nMonthCount)</b> == 1 always, or not?]]>
   </description>
   <pubDate>Sat, 28 Feb 2009 02:30:54 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13522&amp;PID=45996&amp;title=shiftdate-month#45996</guid>
  </item> 
 </channel>
</rss>