Giter Site home page Giter Site logo

Comments (6)

michaelhkay avatar michaelhkay commented on July 18, 2024 1

An alternative approach would be to have a function fn:seconds that returns an xs:dayTimeDuration of a given length, and perhaps a function fn:unix-epoch() that returns the relevant dateTime value, and then you can use these as constants to perform the relevant arithmetic, for example unix-epoch() + $timestamp * seconds(0.001). It also enables you to convert an xs:dayTimeDuration to decimal seconds by doing $dTD div seconds(1). (Perhaps s/unix/posix/)

from qtspecs.

michaelhkay avatar michaelhkay commented on July 18, 2024

While conversion to/from Unix dates and times might be very handy for many users, it's not the only way of representing a date/time as an integer, so I think it should be a much more specific function saying exactly what it does, rather than an overload of the constructor.

If the reason for manipulating the value as a number is for ease of doing calculations, then Julian dates are surely more useful outside the field of Unix computing: they have a higher range and a higher precision.

And if we support Unix datetimes, what about .NET ticks? Some neutrality is called for.

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

That’s helpful, thanks. My proposal was mostly driven by user feedback, but I agree it would be reasonable to strive for a more generic approach.

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

Now that we have fn:seconds, should we also add fn:unix-time? Copied from #984 (review):

[…] we should add an alternative solution for xs:dateTime('1970-01-01T00:00:00Z'). It’s particularly tricky because of the timestamp syntax, and people may be tempted to write things like…

xs:dateTime('1970-01-01T00:00:00') + seconds( (: input from 'date +%s' or similar :) )

…which gives a similar, but wrong result. fn:unix-time() would be my favorite (it seems more common to me than 'epoch', but I may be biased).

from qtspecs.

ndw avatar ndw commented on July 18, 2024

Why does that last example give incorrect results? Because "Z" is misisng?

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

Why does that last example give incorrect results? Because "Z" is missing?

…right. xs:date('1970-01-01') + seconds(...) could be another failed attempt, caused by the complexity of date/time handling.

from qtspecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.