Comments (6)
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.
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.
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.
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.
Why does that last example give incorrect results? Because "Z" is misisng?
from qtspecs.
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)
- Allow sequence constructor in extension instructions that are implemented with named templates HOT 1
- Add a new function `fn:html-doc` HOT 2
- XSLT: add xsl:switch to list of instructions within which whitespace is ignored
- Add decimal-divide function
- fn:apply() - contradiction in spec
- Could the labeling of grammar productions be improved? HOT 2
- Schema validation in XPath HOT 1
- Add xsl:value-of/@as attribute HOT 13
- Generalize for-each-pair to work with any number of input sequences HOT 2
- Further refinement of fn:round() HOT 1
- Declare named record types
- Line endings in unparsed-text-lines() HOT 1
- invisible-xml() return type HOT 2
- Build issue: Unsupported specref to [streamability-fn-distinct-ordered-nodes] HOT 4
- Appendix H of F&O should mention change for unrecognised option parameters
- Missing error conditions for fn:parse-xml() HOT 1
- Delete XQuery Appendix J
- Change obsolete notes on rounding
- In change markup, handle multiple issue or PR numbers
- Almost all functions in FO that must process multiple string items, can have as a parameter only a single collation HOT 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qtspecs.