Tags » Datetime

How to get the latest/earliest moment from a day in Python

Early this week I needed to get the moment 2016-01-01 23:59:59 and 2016-01-01 00:00:00 (an entire day range) for a new feature in which I am working. 187 more words


Timeout czyli kolejny plus dla DateTime.UtcNow

Taki “synchronizator”, który dodatkowo przerwie czekanie po kilku sekundach.

private static void WaitWithTimeout()
    var startTime = DateTime.Now;

    while (true)
        lock (SyncRoot)
            if (!_isOperationInProgress)

        if (DateTime.Now - startTime > TimeSpan.FromSeconds(3))
            throw new TimeoutException("Max duration exceeded");

        Debug.WriteLine("Waiting for xxx with timeout...");
… 113 more words

Converting a string into a DateTime with an exact date format in C# .NET

How do you read the date “03-10-2014”? For some of you this will be October 03 2014. For others, especially those from the US this will be interpreted as March 10 2014. 147 more words


Mocking Django Timezone

I use django.utils.timezone.now() in a lot of my code. It returns the datetime in the timezone specified in settings.py. One side effect of using this function is that during testing, you may want “now()” to be a fixed date time. 127 more words


Various quarter-related DateTime functions in C#

The DateTime object – or struct – lacks functions for quarters. You can e.g. add minutes, months, days etc. to a date but not quarters. 118 more words


Data e Hora Crm 2011 JavaScript

Somar data e incluir no campo

var data = Xrm.Page.data.entity.attributes.get(“sof_data”).getValue(new Date());

var lembrete = Xrm.Page.getAttribute(“sof_lembrete”).getValue();

var dataWorflow = new Date().setDate(data.getDate()+lembrete);


Função para setar hora no campo… 38 more words

Sem Categoria

Truncate a DateTime in C#

Occasionally you need to truncate a date to the nearest year, month, day etc. E.g. you need to transform the date 2015-06-05 15:33:30 into 2015-06-05 00:00:00, i.e. 154 more words