每次月末看到到家都在计算工时够不够,好辛苦,还容易出错,于是就写了个小程序给大家用
大大的彩蛋:https://mp.csdn.net/postedit/82686446
package util
import scala.collection.mutable.ArrayBuffer
import scala.io.Source
object WorkTimeHelper extends App {
val excption = ArrayBuffer[String]()
val workTimeList = Source.fromFile("c:/workTime.txt");
var result: Int = 0
workTimeList.getLines().foreach(e => result += convert(e))
println("result = " + result)
println("excption = " + excption)
def convert(dayItem: String): Int = {
val arr = dayItem.split("\t")
if (arr(1) > "09:00" | arr(2) < "17:30") {
excption += dayItem
0
}
val begin = arr(1).split(":")
val end = arr(2).spl