function toLocaleString()
{
"use strict";
function toDateTimeOptionsAnyAll(opts)
{
var options;
if (opts === @undefined)
options = null;
else if (opts === null)
@throwTypeError("null is not an object");
else
options = @toObject(opts);
var needsDefaults = !options || (
options.weekday === @undefined &&
options.year === @undefined &&
options.month === @undefined &&
options.day === @undefined &&
(!@useIntlDateTimeFormatDayPeriod || options.dayPeriod === @undefined) &&
options.hour === @undefined &&
options.minute === @undefined &&
options.second === @undefined &&
options.fractionalSecondDigits === @undefined
);
if (options) {
var dateStyle = options.dateStyle;
var timeStyle = options.timeStyle;
if (dateStyle !== @undefined || timeStyle !== @undefined)
needsDefaults = false;
}
if (needsDefaults) {
options = @Object.@create(options);
options.year = "numeric";
options.month = "numeric";
options.day = "numeric";
options.hour = "numeric";
options.minute = "numeric";
options.second = "numeric";
}
return options;
}
var value = @thisTimeValue.@call(this);
if (@isNaN(value))
return "Invalid Date";
var options = toDateTimeOptionsAnyAll(@argument(1));
var locales = @argument(0);
return @dateTimeFormat(locales, options, value);
}
function toLocaleDateString()
{
"use strict";
function toDateTimeOptionsDateDate(opts)
{
var options;
if (opts === @undefined)
options = null;
else if (opts === null)
@throwTypeError("null is not an object");
else
options = @toObject(opts);
var needsDefaults = !options || (
options.weekday === @undefined &&
options.year === @undefined &&
options.month === @undefined &&
options.day === @undefined
);
if (options) {
var dateStyle = options.dateStyle;
var timeStyle = options.timeStyle;
if (timeStyle !== @undefined)
@throwTypeError("timeStyle cannot be specified");
if (dateStyle !== @undefined)
needsDefaults = false;
}
if (needsDefaults) {
options = @Object.@create(options);
options.year = "numeric";
options.month = "numeric";
options.day = "numeric";
}
return options;
}
var value = @thisTimeValue.@call(this);
if (@isNaN(value))
return "Invalid Date";
var options = toDateTimeOptionsDateDate(@argument(1));
var locales = @argument(0);
return @dateTimeFormat(locales, options, value);
}
function toLocaleTimeString()
{
"use strict";
function toDateTimeOptionsTimeTime(opts)
{
var options;
if (opts === @undefined)
options = null;
else if (opts === null)
@throwTypeError("null is not an object");
else
options = @toObject(opts);
var needsDefaults = !options || (
(!@useIntlDateTimeFormatDayPeriod || options.dayPeriod === @undefined) &&
options.hour === @undefined &&
options.minute === @undefined &&
options.second === @undefined &&
options.fractionalSecondDigits === @undefined
);
if (options) {
var dateStyle = options.dateStyle;
var timeStyle = options.timeStyle;
if (dateStyle !== @undefined)
@throwTypeError("dateStyle cannot be specified");
if (timeStyle !== @undefined)
needsDefaults = false;
}
if (needsDefaults) {
options = @Object.@create(options);
options.hour = "numeric";
options.minute = "numeric";
options.second = "numeric";
}
return options;
}
var value = @thisTimeValue.@call(this);
if (@isNaN(value))
return "Invalid Date";
var options = toDateTimeOptionsTimeTime(@argument(1));
var locales = @argument(0);
return @dateTimeFormat(locales, options, value);
}