0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-01-03 16:09:41 +00:00
crazy-max_diun/vendor/github.com/dromara/carbon/v2/calendar/julian
2024-12-21 00:26:14 +01:00
..
julian.go switch from durafmt to github.com/dromara/carbon 2024-12-21 00:26:14 +01:00
README.cn.md switch from durafmt to github.com/dromara/carbon 2024-12-21 00:26:14 +01:00
README.jp.md switch from durafmt to github.com/dromara/carbon 2024-12-21 00:26:14 +01:00
README.md switch from durafmt to github.com/dromara/carbon 2024-12-21 00:26:14 +01:00

Julian Day/Modified Julian Day

English | 简体中文 | 日本語

Usage and example

Convert Gregorian calendar to Julian Day
// By default, 6 decimal places are retained for precision
carbon.Parse("2024-01-24 12:00:00").Julian().JD() // 2460334
carbon.Parse("2024-01-24 13:14:15").Julian().JD() // 2460334.051563

// 4 decimal places are retained for precision
carbon.Parse("2024-01-24 12:00:00").Julian().JD(4) // 2460334
carbon.Parse("2024-01-24 13:14:15").Julian().JD(4) // 2460334.0516
Convert Gregorian calendar to Modified Julian Day
// By default, 6 decimal places are retained for precision
carbon.Parse("2024-01-24 12:00:00").Julian().MJD() // 60333.5
carbon.Parse("2024-01-24 13:14:15").Julian().MJD() // 60333.551563

// 4 decimal places are retained for precision
carbon.Parse("2024-01-24 12:00:00").Julian().MJD(4) // 60333.5
carbon.Parse("2024-01-24 13:14:15").Julian().MJD(4) // 60333.5516
Convert Julian Day to Modified Julian Day
// By default, 6 decimal places are retained for precision
carbon.CreateFromJulian(2460334).Julian().MJD() // 60333.5
carbon.CreateFromJulian(2460334.051563).Julian().MJD() // 60332.551563

// 4 decimal places are retained for precision
carbon.CreateFromJulian(2460334).Julian().MJD(4) // 60333.5
carbon.CreateFromJulian(2460334.051563).Julian().MJD(4) // 60332.5516
Convert Modified Julian Day to Julian Day
// By default, 6 decimal places are retained for precision
carbon.CreateFromJulian(60333.5).Julian().JD()() // 2460334
carbon.CreateFromJulian(60333.551563).Julian().JD()() // 2460333.051563

// 4 decimal places are retained for precision
carbon.CreateFromJulian(60333.5).Julian().JD(4) // 2460334
carbon.CreateFromJulian(60333.551563).Julian().JD(4) // 2460333.0516
Convert Julian Day/Modified Julian Day to Gregorian calendar
// Convert Julian Day to Gregorian calendar
carbon.CreateFromJulian(2460334).ToDateTimeString() // 2024-01-24 12:00:00
carbon.CreateFromJulian(2460334.051563).ToDateTimeString() // 2024-01-24 13:14:15

// Convert Modified Julian Day to Gregorian calendar
carbon.CreateFromJulian(60333.5).ToDateTimeString() // 2024-01-24 12:00:00
carbon.CreateFromJulian(60333.551563).ToDateTimeString() // 2024-01-24 13:14:15