1bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
2bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Redistribution and use in source and binary forms, with or without
3bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// modification, are permitted provided that the following conditions are
4bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// met:
5bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//
6bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Redistributions of source code must retain the above copyright
7bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       notice, this list of conditions and the following disclaimer.
8bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Redistributions in binary form must reproduce the above
9bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       copyright notice, this list of conditions and the following
10bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       disclaimer in the documentation and/or other materials provided
11bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       with the distribution.
12bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Neither the name of Google Inc. nor the names of its
13bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       contributors may be used to endorse or promote products derived
14bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       from this software without specific prior written permission.
15bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//
16bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
28bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Create default DateTimeFormat.
29bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgvar dtf = new Intl.DateTimeFormat();
30bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
31bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Array we want to iterate, actual dates are not important.
32bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgvar dateArray = [Date.now(), Date.now(), Date.now()];
33bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
34bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// It shouldn't throw.
35bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// The format() method should be properly bound to the dtf object.
36bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgdateArray.forEach(dtf.format);
37bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
38bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Formatting a date should work in a direct call.
39bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgdtf.format();
40