Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support break time at specific day #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,19 @@ loadDateUtils = function () {
return null;
};

// 日付と時間の配列から、Dateオブジェクトを生成
DateUtils.normalizeDateTime = function(date, time) {
// 日付と時間の配列から、Dateオブジェクトを生成 (休憩時間も考慮)
DateUtils.normalizeDateTime = function(date, time, minutes) {
// 時間だけの場合は日付を補完する
if(date) {
if(!time) date = null;
// 日付だけで時間がなくても、休憩時間がある場合は時間を補完する
if(!time) {
if(!minutes) {
date = null;
}
else {
time = [now().getHours(), now().getMinutes()];
}
}
}
else {
date = [now().getFullYear(), now().getMonth()+1, now().getDate()];
Expand Down
2 changes: 1 addition & 1 deletion scripts/timesheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ loadTimesheets = function (exports) {
this.date = DateUtils.parseDate(message);
this.time = DateUtils.parseTime(message);
this.minutes = DateUtils.parseMinutes(message)
this.datetime = DateUtils.normalizeDateTime(this.date, this.time);
this.datetime = DateUtils.normalizeDateTime(this.date, this.time, this.minutes);
if (this.datetime !== null) {
this.dateStr = DateUtils.format("Y/m/d", this.datetime);
this.datetimeStr = DateUtils.format("Y/m/d H:M", this.datetime);
Expand Down
8 changes: 8 additions & 0 deletions tests/timesheets_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ QUnit.test( "Timesheets", function(assert) {
msgTest('test1', '休憩 30分', [['休憩', 'test1', "30分"]]);
});

// 休憩時間(過去日時)
test1 = {};
var pastDateStr = String(DateUtils.toDate(new Date(2013,11,3,12,0,0)))
test1[pastDateStr] = { user: 'test1', signIn: new Date(2013,11,3,12,0,0), signOut: '-' };
storageTest({'test1': test1}, function(msgTest) {
msgTest('test1', '休憩 30分 12/3', [['休憩', 'test1', "30分"]]);
});

// 休暇申請
storageTest({}, function(msgTest) {
msgTest('test1', 'お休み', []);
Expand Down