Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
short trading days
Browse files Browse the repository at this point in the history
  • Loading branch information
egorFiNE committed Dec 1, 2011
1 parent 9a632d0 commit db432ad
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
26 changes: 26 additions & 0 deletions WorkingDays.js
Expand Up @@ -57,6 +57,32 @@ WorkingDays.nyseHolidays = {
}
}

WorkingDays.nyseShortDays = {
2011: {
11: [25]
}
};

/**
Check if given date is a short trading session at NYSE (MOC @ 13:00)
@param {Date} day date to check.
@return {Boolean}
*/
WorkingDays.isNyseShortDay = function(day) {
var entry = WorkingDays.nyseShortDays[day.getFullYear()];
if (entry) {
entry = entry[day.getMonth()+1];
if (entry) {
return entry.indexOf(day.getDate()) >= 0;
}
}
return false;
}

/**
Check if given date is a holiday at NYSE.
Expand Down
12 changes: 11 additions & 1 deletion docs/WorkingDays.html
Expand Up @@ -39,7 +39,7 @@
<body>
<h1>WorkingDays.js</h1>

<ul><li><a href="#classQworkingdaysQ">WorkingDays()</a></li><li><a href="#staticQmethodQisnyseholidayQday">isNyseHoliday(day)</a></li><li><a href="#staticQmethodQisweekendQday">isWeekend(day)</a></li><li><a href="#staticQmethodQisnyseworkingdayQday">isNyseWorkingDay(day)</a></li><li><a href="#staticQmethodQprevnysedayQday">prevNyseDay(day)</a></li><li><a href="#staticQmethodQnextnysedayQday">nextNyseDay(day)</a></li></ul>
<ul><li><a href="#classQworkingdaysQ">WorkingDays()</a></li><li><a href="#staticQmethodQisnyseshortdayQday">isNyseShortDay(day)</a></li><li><a href="#staticQmethodQisnyseholidayQday">isNyseHoliday(day)</a></li><li><a href="#staticQmethodQisweekendQday">isWeekend(day)</a></li><li><a href="#staticQmethodQisnyseworkingdayQday">isNyseWorkingDay(day)</a></li><li><a href="#staticQmethodQprevnysedayQday">prevNyseDay(day)</a></li><li><a href="#staticQmethodQnextnysedayQday">nextNyseDay(day)</a></li></ul>

<h2><span class="class">WorkingDays()</span></h2>

Expand All @@ -48,6 +48,16 @@ <h2><span class="class">WorkingDays()</span></h2>

<p>See source code for holidays array. </p>

<h3>WorkingDays.isNyseShortDay(<span class="parameter">day</span>) <span class="static">static</span></h3>

<p>Check if given date is a short trading session at NYSE (MOC @ 13:00)</p>

<ul><li><code><span class="type">Date</span></code> <code><strong>day</strong></code> &#8212; date to check.</li></ul>

<p>Returns:</p>

<ul><li><code><span class="type">Boolean</span></code> </li></ul>

<h3>WorkingDays.isNyseHoliday(<span class="parameter">day</span>) <span class="static">static</span></h3>

<p>Check if given date is a holiday at NYSE.</p>
Expand Down
16 changes: 16 additions & 0 deletions test/WorkingDaysTest.js
Expand Up @@ -29,6 +29,22 @@ exports['check nyse working days'] = function(test) {
test.done();
}

exports['check nyse short days'] = function(test) {
process.env.TZ='America/New_York';

test.expect(2);

var day;

day = Date.parseDaystamp('20110903');
test.ok(!WorkingDays.isNyseShortDay(day));

day = Date.parseDaystamp('20111125');
test.ok(WorkingDays.isNyseShortDay(day));
test.done();
}


exports['check nyse prev/next day'] = function(test) {
process.env.TZ='America/New_York';

Expand Down

0 comments on commit db432ad

Please sign in to comment.