Dates are almost certainly more regularly intended, and I'm okay with having it use dates instead of now() format.
As for the usage of now(), the now() format is returned by both now() and os:timestamp(), and is the only way to get subsecond accuracy (if you need it). The primary difference between erlang:now() and os:timestamp() is that erlang:now() is guaranteed to be unique (on a single node), while os:timestamp() is not. The side-effect of this is that erlang:now() run in a very tight loop, the node's sense of time become skewed. So erlang:now() is typically done for uniqueness, while os:timestamp() is done to get microsecond accuracy, but both rely on the now() format. That said, converting from now() to datetime() is trivial (calendar:now_to_datetime()). The reverse of this requires a bit of work, but if you're using qdate, it's just qdate:to_date(Now). Anyway, enough rambling from me this morning. The short of it is that I'm okay with just assuming date() for now. On Thu, Sep 11, 2014 at 4:47 AM, Graeme Defty <[email protected]> wrote: > David, sorry not to have helped you arrive at this choice, but IMHO this is > the right way to go. > > now() values, as I understand it, are principally a way to access a series > of timestamps which are guaranteed monotonically increasing (and therefore > unique). It is not a value-type which should be held as 'data' (that is to > say 'user' data) and so should not occur in database records, other than > perhaps where a unique key is needed. Certainly in my app I use exclusively > date and datetime without a now() in sight. Having to format a now() > specially if I had one would be no hardship - or at the very least, the > lesser of the evils. > > Cheers, > > Graeme > > > > On 11 September 2014 16:35, David Welton <[email protected]> wrote: >> >> I needed to resolve this issue *today* and decided that rather than >> creating special weird datetimes, it's better to have a date be a >> date, and have the JSON code deal in date() values rather than now() >> values, as the former are far more common in models. At least in our >> code. What are others' experiences? >> >> I opened a pull request: >> https://github.com/ChicagoBoss/ChicagoBoss/pull/501 >> >> In theory, now() values should not be negative: >> >> Timestamp = timestamp() >> timestamp() = >> {MegaSecs :: integer() >= 0, >> Secs :: integer() >= 0, >> MicroSecs :: integer() >= 0} >> >> So they're a lot less flexible than dates and datetimes in any case. >> >> I'm happy to keep working on a solution that fits everyone's needs, >> but I needed to pull the trigger on this so that our site wasn't >> showing elderly people being born in 2033. >> >> -- >> David N. Welton >> >> http://www.welton.it/davidw/ >> >> http://www.dedasys.com/ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "ChicagoBoss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> Visit this group at http://groups.google.com/group/chicagoboss. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/chicagoboss/CA%2Bb9R_ux1isNSQyDDrUMvG8vMTZiBVtfnvpPYLirD0vyTq6m5A%40mail.gmail.com. >> For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "ChicagoBoss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at http://groups.google.com/group/chicagoboss. > To view this discussion on the web visit > https://groups.google.com/d/msgid/chicagoboss/CAKF5fiA-WsRWHGdnDuRu%2Buz0%3D1CMENMre-U7L9MFxoG7BddxTg%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm -- You received this message because you are subscribed to the Google Groups "ChicagoBoss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at http://groups.google.com/group/chicagoboss. To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAPTXyXf-0QRp%2B9wYB2btTQedvBv0PPC0bgrRD5DX2cdR7w_2Lw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
