我从jde表收到朱利安日期和时间:
thing = [[1,2], [3,4]]
p thing.send(:[], 1) # => [3,4]
p thing.send(:[], 1).send(:[], 0) # => 3
thing.send(:[], 1).send(:[]=, 0, 5)
p thing # => [[1,2], [5,4]]
我需要将它们转换为常规日期和时间值以集成到我的应用程序中。
虽然我能够使用自定义代码协调日期部分:
SLUPMJ(Date) | SLTDAY(Time)
---------------------------
116173 | 94959
如何转换DCY = Left(Date1, 3)
If Left(DCY, 1) = "0" Then
DYear = "19" & Right(DCY, 2)
Else
DYear = "20" & Right(DCY, 2)
End If
Dinterval = CInt(Right(Date1, 3))
TDate = DateAdd("d", Dinterval - 1, "01/01/" & DYear)
J2D2 = Day(TDate) & "/" & Month(TDate) & "/" & Year(TDate)
中的时间部分?
答案 0 :(得分:1)
这里有一些代码用于转换Julian日期时间的时间部分。可能有一种更简单的方法,但编码应该很难!™:)
''' <summary>
''' Converts the time portion of a Julian datetime
''' </summary>
''' <param name="dJDateTime">The Julian datetime. For example: 2457984.021181</param>
''' <returns>The time, formatted as follows: d:hh:mm:ss.mmm</returns>
Function ConvertJulianTime(ByVal dJDateTime As Decimal) As String
' Julian time is calculated as a fraction of a 24-hour period, starting from noon.
' So a value >= .5 is a morning hour on the next day
' Get the fractional part of the Julian datetime, which is the time
Dim dJTime As Decimal = GetFractionalPart(dJDateTime)
' Get time in seconds
Dim dJTimeInSec As Decimal = 86400 * dJTime + 43200 ' 43200 is half a day in seconds
' Calculate the hours
Dim dJTimeInHours As Decimal = dJTimeInSec / 3600
' If the value is >= 24, it's a morning hour so increment the day value
Dim intDay As Integer = 0
If dJTimeInHours >= 24 Then
dJTimeInHours = dJTimeInHours - 24
intDay = 1
End If
' Calculate the minutes
Dim dJTimeInHoursMin As Decimal = GetFractionalPart(dJTimeInHours) * 60
' Calculate the seconds
Dim dJTimeInHoursSec As Decimal = GetFractionalPart(dJTimeInHoursMin) * 60
' Calculate the milliseconds
Dim dJTimeInHoursMSec As Decimal = GetFractionalPart(dJTimeInHoursSec) * 1000
' Build the result and display it
Dim tsSpan As New TimeSpan(intDay, CInt(Math.Truncate(dJTimeInHours)),
CInt(Math.Truncate(dJTimeInHoursMin)),
CInt(Math.Truncate(dJTimeInHoursSec)),
CInt(Math.Truncate(dJTimeInHoursMSec)))
Return tsSpan.ToString("d\:hh\:mm\:ss\.fff")
End Function
''' <summary>
''' Given a decimal, gets the fractional part only. For example, for 1234.5678, returns 0.5678
''' </summary>
''' <param name="dNumber">The decimal.</param>
''' <returns>The fractional part of the decimal.</returns>
Function GetFractionalPart(ByVal dNumber As Decimal) As Decimal
Dim dInt As Decimal = Math.Truncate(dNumber)
Return (dNumber - dInt)
End Function
结束班