now
Number of milliseconds since midnight 01 January 1970 UTC to the present moment ignoring leap seconds.
static func now() -> Double
Number of milliseconds since midnight 01 January 1970 UTC to the present moment ignoring leap seconds.
static func now() -> Double
import JavaScriptKit
Swift framework to interact with JavaScript through WebAssembly.
final class JSDate
A wrapper around the JavaScript Date
class that exposes its properties in a type-safe way. This doesn’t 100% match the JS API, for example getMonth
/setMonth
etc accessor methods are converted to properties, but the rest of it matches in the naming. Parts of the JavaScript Date
API that are not consistent across browsers and JS implementations are not exposed in a type-safe manner, you should access the underlying jsObject
property if you need those.
@frozen struct Double
A double-precision, floating-point value type.
init(millisecondsSinceEpoch: Double? = nil)
Creates a new instance of the JavaScript Date
class with a given amount of milliseconds that passed since midnight 01 January 1970 UTC.
init(unsafelyWrapping jsObject: JSObject)
init(year: Int, monthIndex: Int, day: Int = 1, hours: Int = 0, minutes: Int = 0, seconds: Int = 0, milliseconds: Int = 0)
According to the standard, monthIndex
is zero-indexed, where 11
is December. day
represents a day of the month starting at 1
.
static var constructor: JSFunction? { get }
The constructor function used to create new Date
objects.
var date: Int { get set }
The day of the month in 1..31
range in local time zone.
var day: Int { get }
The day of the week in 0..6
range in local time zone.
var fullYear: Int { get set }
Year of this date in local time zone.
var hours: Int { get set }
The amount of hours in this day from 0..23
range in local time zone.
let jsObject: JSObject
The underlying JavaScript Date
object.
var milliseconds: Int { get set }
The amount of milliseconds in this second 0..999
range in local time zone.
var minutes: Int { get set }
The amount of minutes in this hours from 0..59
range in local time zone.
var month: Int { get set }
Month of this date in 0–11
range in local time zone.
var seconds: Int { get set }
The amount of seconds in this minute from 0..59
range in local time zone.
var timezoneOffset: Int { get }
Offset in minutes between the local time zone and UTC.
var utcDate: Int { get set }
The day of the month in 1..31
range in the UTC time zone.
var utcDay: Int { get }
The day of the week in 0..6
range in the UTC time zone.
var utcFullYear: Int { get set }
Year of this date in the UTC time zone.
var utcHours: Int { get set }
The amount of hours in this day from 0..23
range in the UTC time zone.
var utcMilliseconds: Int { get set }
The amount of milliseconds in this second 0..999
range in the UTC time zone.
var utcMinutes: Int { get set }
The amount of minutes in this hours from 0..59
range in the UTC time zone.
var utcMonth: Int { get set }
Month of this date in 0–11
range in the UTC time zone.
var utcSeconds: Int { get set }
The amount of seconds in this minute from 0..59
range in the UTC time zone.
static func < (lhs: JSDate, rhs: JSDate) -> Bool
static func == (lhs: JSDate, rhs: JSDate) -> Bool
func toISOString() -> String
Returns a string conforming to ISO 8601 that contains date and time, e.g. "2020-09-15T08:56:54.811Z"
.
func toLocaleDateString() -> String
Returns a string with date parts in a format defined by user’s locale, e.g. "9/15/2020"
.
func toLocaleTimeString() -> String
Returns a string with time parts in a format defined by user’s locale, e.g. "10:04:14"
.
func toUTCString() -> String
Returns a string formatted according to rfc7231 and modified according to ecma-262, e.g. Tue, 15 Sep 2020 09:04:40 GMT
.
func valueOf() -> Double
Number of milliseconds since midnight 01 January 1970 UTC to the given date ignoring leap seconds.