Last active
August 9, 2018 23:22
-
-
Save mikehibm/cf26fd6d846051561380a9c4f467e9cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as moment from 'moment'; | |
export interface WorkItem { | |
user: string; | |
client: string; | |
project: string; | |
description: string; | |
startDate: Date; | |
endDate: Date; | |
duration: number; | |
} | |
export function mapArrayToWorkItem(data: string[][]): WorkItem[] { | |
return data | |
.map((row) => { | |
const startDate = moment(`${row[4]} ${row[5]}`, 'YYYY-MM-DD HH:mm:ss'); | |
const endDate = moment(`${row[6]} ${row[7]}`, 'YYYY-MM-DD HH:mm:ss'); | |
const duration = moment.duration(endDate.diff(startDate)); | |
return { | |
user: row[0], | |
client: row[1], | |
project: row[2], | |
description: row[3], | |
startDate: startDate.toDate(), | |
endDate: endDate.toDate(), | |
duration: duration.asHours() | |
}; | |
}) | |
.filter((i) => i.client !== 'Client' && i.client); // 先頭と末尾の行を除外。 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment