<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Moonshine Project Dev Blog &#187; Uncategorized</title>
	<atom:link href="http://blog.moonshine-project.com/en/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.moonshine-project.com/en</link>
	<description>iPhone app dev whatnots</description>
	<lastBuildDate>Sun, 25 Apr 2010 17:10:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Exploring NSDateFormatter using F-Script as a REPL</title>
		<link>http://blog.moonshine-project.com/en/2010/04/26/exploring-nsdateformatter-using-f-script-as-a-repl/</link>
		<comments>http://blog.moonshine-project.com/en/2010/04/26/exploring-nsdateformatter-using-f-script-as-a-repl/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 16:33:01 +0000</pubDate>
		<dc:creator>ento</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonshine-project.com/en/?p=44</guid>
		<description><![CDATA[(here be preface)
Let&#8217;s start by instantiating a formatter and a date.

&#62; fmt := NSDateFormatter new.
&#160;
&#62; fmt
&#60;NSDateFormatter: 0x2004cec80&#62;
&#160;
&#62; now := NSDate date.
&#160;
&#62; now
2010-04-25 18:03:26 +0900

Note that assignment is :=, not =, and no angled brackets around method calls. Also, a sentence ends in a period, not a semicolon.
OK, what does the virgin formatter output when we [...]]]></description>
			<content:encoded><![CDATA[<p>(here be preface)</p>
<p>Let&#8217;s start by instantiating a formatter and a date.</p>

<div class="wp_syntax"><div class="code"><pre class="smalltalk" style="font-family:monospace;">&gt; <span style="color: #00007f;">fmt</span> <span style="color: #000066; font-weight:bold;">:=</span> <span style="color: #0000ff;">NSDateFormatter</span> new.
&nbsp;
&gt; fmt
&lt;<span style="color: #0000ff;">NSDateFormatter</span>: <span style="color: #00007f;">0x2004cec80</span>&gt;
&nbsp;
&gt; <span style="color: #00007f;">now</span> <span style="color: #000066; font-weight:bold;">:=</span> <span style="color: #0000ff;">NSDate</span> date.
&nbsp;
&gt; now
<span style="color: #7f0000;">2010</span>-<span style="color: #00007f;">04</span>-<span style="color: #00007f;">25</span> <span style="color: #7f0000;">18</span>:<span style="color: #00007f;">03</span>:<span style="color: #00007f;">26</span> +<span style="color: #00007f;">0900</span></pre></div></div>

<p>Note that assignment is :=, not =, and no angled brackets around method calls. Also, a sentence ends in a period, not a semicolon.</p>
<p>OK, what does the virgin formatter output when we feed it a date?</p>

<div class="wp_syntax"><div class="code"><pre class="smtalltalk" style="font-family:monospace;">&gt; fmt stringFromDate:now
''</pre></div></div>

<p>Hmm, after consulting the Xcode Developer Documentation, it seems that we need to set a format string to get a non-empty result. There are also shortcut methods provided to easily set the formats for the date part and the time part.</p>
<p>The argument to these methods is a constant, which we have easy access to in F-Script.</p>

<div class="wp_syntax"><div class="code"><pre class="smtalltalk" style="font-family:monospace;">&gt; NSDateFormatterNoStyle
0
&nbsp;
&gt; fmt setDateStyle:NSDateFormatterMediumStyle
&nbsp;
&gt; fmt dateFormat
'MMM d, yyyy'
&nbsp;
&gt; fmt stringFromDate:now
'Apr 25, 2010'</pre></div></div>

<p>There, the date. Let&#8217;s try setting the time part format.</p>

<div class="wp_syntax"><div class="code"><pre class="smtalltalk" style="font-family:monospace;">&gt; fmt setTimeStyle:NSDateFormatterMediumStyle
&nbsp;
&gt; fmt dateFormat
'MMM d, yyyy h:mm:ss a'
&nbsp;
&gt; fmt stringFromDate:now
'Apr 25, 2010 6:03:26 PM'</pre></div></div>

<p>With #setDateFormat:, we have more control over the formatting. You can even include arbitrary string. (Which I found out after reading the <a href="http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns">date format patterns specification</a> adopted by NSDateFormatter.)</p>

<div class="wp_syntax"><div class="code"><pre class="smtalltalk" style="font-family:monospace;">&gt; fmt setDateFormat:'''Year''YYYY'
&nbsp;
&gt; fmt dateFormat
''Year'YYYY'
&nbsp;
&gt; fmt stringFromDate:now
'Year2010'</pre></div></div>

<p>(Note: this is a draft. More details will be filled in afterwards.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonshine-project.com/en/2010/04/26/exploring-nsdateformatter-using-f-script-as-a-repl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://blog.moonshine-project.com/en/2009/07/07/hello-world/</link>
		<comments>http://blog.moonshine-project.com/en/2009/07/07/hello-world/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 07:07:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to Moonshine Project.
]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://www.moonshine-project.com/">Moonshine Project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonshine-project.com/en/2009/07/07/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

