.net - Julian Date and Time to regular Date and Time -


i receiving julian date , time jde table as:

slupmj(date) | sltday(time)  --------------------------- 116173       | 94959 

i need convert them regular date , time values integrate application.

while able concert date part using custom code:

dcy = left(date1, 3)  if left(dcy, 1) = "0"     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) 

how convert time part in vb.net?

here's code convert time portion of julian datetime. there simpler way, coding should hard!™ :)

''' <summary> ''' converts time portion of julian datetime ''' </summary> ''' <param name="djdatetime">the julian datetime. example: 2457984.021181</param> ''' <returns>the time, formatted follows: d:hh:mm:ss.mmm</returns> function convertjuliantime(byval djdatetime decimal) string     ' julian time calculated fraction of 24-hour period, starting noon.      ' value >= .5 morning hour on next day      ' fractional part of julian datetime, time     dim djtime decimal = getfractionalpart(djdatetime)     ' time in seconds     dim djtimeinsec decimal = 86400 * djtime + 43200 ' 43200 half day in seconds     ' calculate hours     dim djtimeinhours decimal = djtimeinsec / 3600     ' if value >= 24, it's morning hour increment day value     dim intday integer = 0     if djtimeinhours >= 24         djtimeinhours = djtimeinhours - 24         intday = 1     end if     ' calculate minutes     dim djtimeinhoursmin decimal = getfractionalpart(djtimeinhours) * 60     ' calculate seconds     dim djtimeinhourssec decimal = getfractionalpart(djtimeinhoursmin) * 60     ' calculate milliseconds     dim djtimeinhoursmsec decimal = getfractionalpart(djtimeinhourssec) * 1000     ' build result , display     dim tsspan 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 decimal, gets fractional part only. example, 1234.5678, returns 0.5678 ''' </summary> ''' <param name="dnumber">the decimal.</param> ''' <returns>the fractional part of decimal.</returns> function getfractionalpart(byval dnumber decimal) decimal     dim dint decimal = math.truncate(dnumber)     return (dnumber - dint) end function 

end class


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -