Skip to content

Instantly share code, notes, and snippets.

@mahmut-gundogdu
Created October 31, 2019 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmut-gundogdu/83e3e531369d19a88db8d0e33693836c to your computer and use it in GitHub Desktop.
Save mahmut-gundogdu/83e3e531369d19a88db8d0e33693836c to your computer and use it in GitHub Desktop.
Giriş ve çıkış çıktısı hesaplayıcısı. repl.it https://repl.it/@mahmut_gundogdu/EasySoupyEntropy-1
const moment = require('moment')
var mg = `01-10-2019;08:01;17:31
02-10-2019;07:57;18:14
03-10-2019;07:55;17:34
04-10-2019;07:59;17:32
07-10-2019;08:06;17:19
08-10-2019;07:54;17:11
09-10-2019;08:01;17:13
10-10-2019;07:59;17:36
11-10-2019;08:01;17:10
14-10-2019;07:55;17:30
15-10-2019;07:59;17:39
16-10-2019;07:59;17:08
17-10-2019;08:00;17:37
18-10-2019;07:56;17:50
21-10-2019;07:58;18:42
22-10-2019;07:59;15:42
23-10-2019;07:58;18:41;07:58;11:01;12:47;18:41
24-10-2019;08:03;17:29
25-10-2019;09:23;18:00
30-10-2019;08:07;17:07`
var dates = mg.split('\n').map(x => {
let item = x.split(';')
let data = { date: item[0], start: moment(item[1], 'HH:mm'), end: moment(item[2], 'HH:mm') ,a1:'',a2:'' }
let diff = data.end.diff(data.start)
diff = moment.duration(diff)
data.diff = (diff.hours() - 9) + ':' + String(diff.minutes()).padStart(2,'0')
let startHour = data.start.hours()
let startMinues = data.start.minutes()
var dateStr = data.date.replace(/-/g,'.')
data.a1 = dateStr + ' 08:00' +';' +dateStr +' '+item[1]
var dateStr = data.date.replace(/-/g,'.')
data.a2 = dateStr + ' 17:00' +';'+ dateStr + ' '+item[2]
return data;
})
const izin=dates.filter(x=> !!x.a1).map(x=> x.a1)
const mesai=dates.filter(x=> !!x.a2).map(x=> x.a2)
const toplam = dates.map(x=> x.a1+';'+x.a2)
console.log('izinler', izin.join('\n'))
console.log('mesai', mesai.join('\n'))
console.log('toplam\n', toplam.join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment