Is there a natural language parser for date/times in ColdFusion?
There's a (reportedly -- I've not used it) good one for Java called JChronic -- a port of the Ruby Chronic date parser. You could try using it.
It hasn't been updated since 2006, but should still be useful.
I believe parseDateTime() and lsParseDateTime() are the closest to what you're looking for, from the library of built-in ColdFusion functions.
Check out Adobe's LiveDocs for other date/time functions.
Remember that you can also leverage any Java date/time class as well. Pete Freitag has an interesting post with some example code.
Since you are probably using it in a form anyway checkout Datejs, a very nice javascript date library that can parse a lot of dates. It is very easy to incorporate with CF.
Related
I struggled with this for hours before finding out that you have to use from_ instead of from when using gremlin javascript.
After digging through the source code I finally found out that the code is using from_ instead of from (see code). Since I'm a newbie this comes off as strange because its counterpart to is still to (and not to_, see code here)
I googled everywhere but couldn't find the reason why this works this way, and feel uneasy about using the underscore version since most of the times underscores denote private methods that users should not really trust.
Also, is there an official documentation page for gremlin javascript somewhere I'm missing? I'm concerned I may run into these problems in the future and there's not really an official documentation for the JavaScript version and I may need to go through the same struggle. I like gremlin, but if the JavaScript version is not stable and should not be used, I might as well look into other alternatives than Tinkerpop suites.
Gremlin Language Variants (GLVs) are given some latitude in terms of how they implement the Gremlin language so that it feels as close to the syntax and programming idioms of the native language and thus avoid too much pollution from Java. In other words, if you're using gremlin-javascript it should feel like your coding in JS and not Java. So, you will see slight differences among GLVs from time to time.
So, with respect to from_ specifically, we typically use an underscore when we have a conflict in a native language with a reserved keyword. In Java from is fully acceptable, but in other languages it is not. For Javascript, from is currently not a reserved word, but we are preparing for the eventual form of import ... from which is coming in the future.
As for documentation, I'm not aware of too much more than what you have already found on the TinkerPop web site. We hope to have more examples and information available in our next release.
I struggled with this for hours before finding out that you have to use from_ instead of from when using gremlin javascript.
After digging through the source code I finally found out that the code is using from_ instead of from (see code). Since I'm a newbie this comes off as strange because its counterpart to is still to (and not to_, see code here)
I googled everywhere but couldn't find the reason why this works this way, and feel uneasy about using the underscore version since most of the times underscores denote private methods that users should not really trust.
Also, is there an official documentation page for gremlin javascript somewhere I'm missing? I'm concerned I may run into these problems in the future and there's not really an official documentation for the JavaScript version and I may need to go through the same struggle. I like gremlin, but if the JavaScript version is not stable and should not be used, I might as well look into other alternatives than Tinkerpop suites.
Gremlin Language Variants (GLVs) are given some latitude in terms of how they implement the Gremlin language so that it feels as close to the syntax and programming idioms of the native language and thus avoid too much pollution from Java. In other words, if you're using gremlin-javascript it should feel like your coding in JS and not Java. So, you will see slight differences among GLVs from time to time.
So, with respect to from_ specifically, we typically use an underscore when we have a conflict in a native language with a reserved keyword. In Java from is fully acceptable, but in other languages it is not. For Javascript, from is currently not a reserved word, but we are preparing for the eventual form of import ... from which is coming in the future.
As for documentation, I'm not aware of too much more than what you have already found on the TinkerPop web site. We hope to have more examples and information available in our next release.
Are there any existing implementations in R to parse ISO8601 strings into POSIXt objects? The ISO8601 spec allows date/times to be printed in a variety of (non-overlapping) formats, so one probably needs to do some regular expression magic to detect the format and feed that to strptime.
Doing this properly might actually be quite challenging, however something that detects the most common formats would already be very helpful. I can hardly imagine I am the first one to run into this, but I am having a hard time finding good implementations.
Strictly speaking, you can't. I don't need to know anything about r or cran (or even what they are) to tell you that, because I know ISO 8601 well enough to know that just knowing something is ISO 8601 is not enough to unambiguously know that what is meant by it, especially in the shorter forms.
Find out what profile of ISO 8601 the other party is using. If they don't know what you're talking about, then you will be doing them a favour when you point out what I just said in the paragraph above. As I wrote once elsewhere,
Unfortunately many people think of a particular profile they are familiar with when they hear “ISO 8601”, other people know that using 8601 is a Good Thing but are not familiar with the details of implementation. Hence a spec or requirements document might mention 8601 but not be more explicit than that. In such cases it’s important to seek clarification rather than assume that the format you think of as “ISO 8601” is the correct one to use.
So, tell them "'ISO 8601' is not specific enough, I need to know exactly what you are doing, what your limits on precision are." (And possibly what your policy on dates prior to 1582 and perhaps again prior to 0001 are, your policy on leap-seconds, and a few other things left open but the standard)
Then whatever you're dealing with should be easy enough: Aside from this point of ambiguity, it is a pretty straight-forward standard. It should just be thought of as a standard about defining date formats, more than one that defines a date format.
See .parseISO8601 in the xts package for one implementation. I doubt this will work "out of the box", but it should give you a good idea how to implement your specific needs.
This looks promising: http://cran.r-project.org/web/packages/parsedate
parsedate: Recognize and Parse Dates in Various Formats, Including All
ISO 8601 Formats
Parse dates automatically, without the need of specifying a format.
Currently it includes the git date parser. It can also recognize and
parse all ISO 8601 formats.
t <- strptime("2013-08-20T14:56:37", "%FT%T")
worked well enough for me for most cases. It already fails on fractions of seconds though and does not include solutions to all the problems Jon Hanna mentioned. (And which make working with time data types so unbelievably difficult.)
I'm trying to retrieve the date only from a java.util.date. I know I can set the time to 0 but I'm searching for a cleaner, more concise way if possible. Does this exist?
Thanks!
Krt_Malta
The cleaner way is to use Joda Time to start with, where there are separate concepts of LocalDate, LocalTime, LocalDateTime, DateTime, Instant etc.
You can translate between java.util.Date and the Joda types, but I would suggest you stick to using Joda for as much of the code as you can, and only translate when you really need to.
Sorry if you'd hoped to avoid an extra library - but Joda is so much better than the built-in API, it's well worth investing in the effort IMO. Note that within the Java types you'll need to determine which time zone you're interested in - java.util.Date defines an instant in time, which may occur in as many as three different dates around the world depending on your time zone.
Another option is the truncate method in the DateUtils library. You put in the date and the field up to which you are interested (in this case CALENDAR.DAY_OF_MONTH). The rest will be set to 0. Effectively:
DateUtils.truncate(Calendar.getInstance(), Calendar.DAY_OF_MONTH).getTime()
did the job.
More info about the method is at: http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/time/DateUtils.html#truncate%28java.lang.Object,%20int%29
Are there any real world applications written in the Clean programming language? Either open source or proprietary.
This is not a direct answer, but when I checked last time (and I find the language very interesting) I didn't find anything ready for real-world.
The idealist in myself always wants to try out new languagages, very hot on my list (apart from the aforementioned very cool Clean Language) is currently (random order) IO, Fan and Scala...
But in the meantime I then get my pragmatism out and check the Tiobe Index. I know you can discuss it, but still: It tells me what I will be able to use in a year from now and what I possibly won't be able to use...
No pun intended!
I am using Clean together with the iTasks library to build websites quite easy around workflows.
But I guess another problem with Clean is the lack of documentation and examples: "the Clean book" is from quite a few years back, and a lot of new features don't get documented except for the papers they publish.
http://clean.cs.ru.nl/Projects page doesn't look promising :) It looks like just another research project with no real-world use to date.
As one of my professors at college has been involved in the creation of Clean, it was no shock he'd created a real world application. The rostering-program of our university was created entirely in Clean.
The Clean IDE and the Clean compiler are written in Clean. (http://wiki.clean.cs.ru.nl/Download_Clean)
Cloogle, a search engine for Clean libraries, syntax, etc. (like Hoogle for Haskell) is written in Clean. Its source is on Radboud University's GitLab instance (web frontend; engine).