MCPcopy Index your code
hub / github.com/apache/devlake / parseDate

Function parseDate

backend/plugins/q_dev/tasks/s3_data_extractor.go:403–421  ·  view source on GitHub ↗

解析日期

(dateStr string)

Source from the content-addressed store, hash-verified

401
402// 解析日期
403func parseDate(dateStr string) (time.Time, errors.Error) {
404 // 尝试常见的日期格式
405 formats := []string{
406 "2006-01-02",
407 "2006/01/02",
408 "01/02/2006",
409 "01-02-2006",
410 time.RFC3339,
411 }
412
413 for _, format := range formats {
414 date, err := time.Parse(format, dateStr)
415 if err == nil {
416 return date, nil
417 }
418 }
419
420 return time.Time{}, errors.Default.New(fmt.Sprintf("failed to parse date: %s", dateStr))
421}
422
423// 解析整数
424func parseInt(fieldMap map[string]string, field string) int {

Callers 3

TestParseDateFunction · 0.85
createUserReportDataFunction · 0.85

Calls 1

NewMethod · 0.65

Tested by 1

TestParseDateFunction · 0.68