c# - How to find the the start and end of a yesterday with Noda Time? -


this question has answer here:

i'm trying the first/last milliseconds yesterday (which applies other dates too) noda time, , think i'm close not sure if have done right.

if convert yesterday.atmidnight() ticks add number of ticks in day minus 1 give me end time. make sense , correct usage of noda time given requirements?

thank you, stephen

//come begin , end parameters in milliseconds oracle query  //assumption code run midnight 4am //assumption application code run on servers in midwest usa //assumption database servers on west coast usa   instant = systemclock.instance.now; duration duration = duration.fromhours(24); localdate yesterday = now.inutc().minus(duration).date;  console.writeline(yesterday.atmidnight());  // add day minus 1 tick 

update

the noda docs show period.between might useful too, test out.

doesn't seem should more difficult this:

public static void defineyesterday( out localdatetime yesterdaystartofday , out localdatetime yesterdayendofday ) {   bcldatetimezone tz         = nodatime.timezones.bcldatetimezone.forsystemdefault() ;   localdatetime          = systemclock.instance.now.inzone(tz).localdatetime ;   localdatetime   startofday = now.plusticks( - now.tickofday ) ;    yesterdaystartofday = startofday.plusdays(  -1 ) ;   yesterdayendofday   = startofday.plusticks( -1 ) ;    return; } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -