浏览代码

LibJS: Pad abs(year) < 1000 with zeros in Date.prototype.toString()

Linus Groh 4 年之前
父节点
当前提交
674f3d0347
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Userland/Libraries/LibJS/Runtime/Date.h

+ 2 - 1
Userland/Libraries/LibJS/Runtime/Date.h

@@ -53,7 +53,8 @@ public:
         m_milliseconds = milliseconds;
         m_milliseconds = milliseconds;
     }
     }
 
 
-    String date_string() const { return m_datetime.to_string("%a %b %d %Y"); }
+    // FIXME: Support %04Y in Core::DateTime::to_string()
+    String date_string() const { return String::formatted(m_datetime.to_string("%a %b %d {:04}"), m_datetime.year()); }
     // FIXME: Deal with timezones once SerenityOS has a working tzset(3)
     // FIXME: Deal with timezones once SerenityOS has a working tzset(3)
     String time_string() const { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
     String time_string() const { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
     String string() const
     String string() const