<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Daniel</title>
    <description>The latest articles on Forem by Daniel (@danielmorgan).</description>
    <link>https://forem.com/danielmorgan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F189971%2F61599c08-fc01-4d26-8e56-10d1fd253da3.jpg</url>
      <title>Forem: Daniel</title>
      <link>https://forem.com/danielmorgan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/danielmorgan"/>
    <language>en</language>
    <item>
      <title>Better Looking Dates in Eleventy: Jan 01 2023 --&gt; Jan 1st 2023</title>
      <dc:creator>Daniel</dc:creator>
      <pubDate>Fri, 06 Jan 2023 17:43:11 +0000</pubDate>
      <link>https://forem.com/danielmorgan/better-looking-dates-in-eleventy-jan-01-2023-jan-1st-2023-46oe</link>
      <guid>https://forem.com/danielmorgan/better-looking-dates-in-eleventy-jan-01-2023-jan-1st-2023-46oe</guid>
      <description>&lt;p&gt;By default, the default &lt;code&gt;readableDate&lt;/code&gt; in Eleventy will output dates like: &lt;code&gt;Dec 03 2022&lt;/code&gt;. Let's do better and set this up as the ordinal date. &lt;/p&gt;

&lt;p&gt;For most numbers, we end with th:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    let ordinalSuffix = "th";
    if (day === 1 || day === 21 || day === 31) {
      ordinalSuffix = "st";
    } else if (day === 2 || day === 22) {
      ordinalSuffix = "nd";
    } else if (day === 3 || day === 23) {
      ordinalSuffix = "rd";
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the full code for .eleventy.js or your date converter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  function convertDate(dateString) {
    const date = new Date(dateString);
    const day = date.getDate();
    const month = date.getMonth();
    const year = date.getFullYear();
    const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    const monthName = monthNames[month];

    let ordinalSuffix = "th";
    if (day === 1 || day === 21 || day === 31) {
      ordinalSuffix = "st";
    } else if (day === 2 || day === 22) {
      ordinalSuffix = "nd";
    } else if (day === 3 || day === 23) {
      ordinalSuffix = "rd";
    }

    return `${monthName} ${day}${ordinalSuffix}, ${year}`;
  }

  eleventyConfig.addFilter("readableDate", dateObj =&amp;gt; {
    // Convert the date object to a date string using the convertDate() function 
    // And make sure you have nd, st, rd, or th after the day
    var dateString = convertDate(dateObj);
    return dateString;
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function takes advantage of the fact that most dates are ordinaled (if that's a word) with 'th'. We just have to add st to 1, 21, and 31... and then nd to 2 and 22, and we can't forget rd tacked onto 3 and 23. &lt;/p&gt;

</description>
      <category>ui</category>
      <category>design</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Update everything on a Mac</title>
      <dc:creator>Daniel</dc:creator>
      <pubDate>Tue, 10 May 2022 14:47:57 +0000</pubDate>
      <link>https://forem.com/danielmorgan/update-everything-on-a-mac-41mp</link>
      <guid>https://forem.com/danielmorgan/update-everything-on-a-mac-41mp</guid>
      <description>&lt;p&gt;(requires homebrew) &lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew update &amp;amp;&amp;amp; brew outdated &amp;amp;&amp;amp; brew upgrade &amp;amp;&amp;amp; brew cu -ay &amp;amp;&amp;amp; brew upgrade --cask --greedy &amp;amp;&amp;amp; softwareupdate -i -a &amp;amp;&amp;amp; brew cleanup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;First, it updates homebrew, upgrades packages, updates casks (ones managed by homebrew and those not as well), then gets apple updates, followed by a cleanup. &lt;/p&gt;

</description>
      <category>automation</category>
    </item>
  </channel>
</rss>
