1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibJS: Implement Date.getUTC*

Test files created with:
    $ for f in Libraries/LibJS/Tests/builtins/Date/Date.prototype.get*js; do
          cp $f $(echo $f | sed -e 's/get/getUTC/') ;
      done
    $ rm Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCTime.js
    $ git add Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTC*.js
    $ ls Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTC*.js | \
          xargs sed -i -e 's/get/getUTC/g'
This commit is contained in:
Nico Weber 2020-08-23 13:30:18 -04:00 committed by Andreas Kling
parent d5eaefe87b
commit ad00462daa
12 changed files with 184 additions and 4 deletions

View file

@ -54,6 +54,15 @@ public:
double time() const { return datetime().timestamp() * 1000.0 + milliseconds(); }
int year() const { return datetime().day(); }
int utc_date() const;
int utc_day() const;
int utc_full_year() const;
int utc_hours() const;
int utc_milliseconds() const { return milliseconds(); }
int utc_minutes() const;
int utc_month() const;
int utc_seconds() const { return seconds(); }
String date_string() const { return m_datetime.to_string("%a %b %d %Y"); }
// FIXME: Deal with timezones once SerenityOS has a working tzset(3)
String time_string() const { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
@ -75,6 +84,7 @@ public:
}
private:
tm to_utc_tm() const;
virtual bool is_date() const final { return true; }
Core::DateTime m_datetime;