Questions tagged [clj-time]

23 questions
11
votes
1 answer

Get difference between DateTime instances with clj-time

I am trying to calculate the difference between two DateTime instances using clj-time. I looked through the documentation and found clj-time.core/minus and clj-time.core/minus- but both require an instance of org.joda.time.ReadablePeriod and not one…
davenportw15
  • 157
  • 2
  • 10
8
votes
4 answers

How do I add days to a date in Clojure

I have looked at the following question: How to add days to current date in clojure. However I am very new to Clojure and I am getting stuck on the following scenario I am getting the timestamp in string format. So I am parsing it using the…
newbie
  • 391
  • 1
  • 6
  • 20
7
votes
1 answer

How can I “unparse” a date in a specific time zone?

Using clj-time, I can parse a date and time by doing (def timestamp (format/parse (formatters :date-time-no-ms) "2013-06-03T23:00:00-0500")) ;=> # I can convert this back into a string…
bdesham
  • 15,430
  • 13
  • 79
  • 123
4
votes
2 answers

Convert Clojure #inst instant in time to Joda time with clj-time

What is the right way to parse Clojure time instants like #inst "2017-01-01T12:00:00" to Joda time using the clj-time library?
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
3
votes
1 answer

clj-time.coerce java.sql.Date .toString decrements date?

test_ns.clj (ns test-ns (:require [clj-time.jdbc :as tj] [clj-time.coerce :as tc])) (.toString (tc/to-sql-date (tc/from-string "2018-09-28"))) => "2018-09-27" Why does .toString decrement the date? The expectation is that the…
skullgoblet1089
  • 554
  • 4
  • 12
3
votes
1 answer

Clojure change date after add to postgresql

I'm having a problem with clojure and postgresql. When I insert, for example, "2017-06-27" to DB (date format column) it saves "2017-06-26" and when I select this result, the object returned is #inst "2017-06-28T03:00:00.000-00:00" The most strange…
pitalig
  • 177
  • 1
  • 4
3
votes
1 answer

Determine the date format by locale with clj-time

I have been searching for this for quite a while now through Google and I couldn't find an ultimate solution with clj-time. I want to format a date automatically by the locale, like in this example or here. How would I do this using clj-time? Thanks…
RaceCondition
  • 307
  • 2
  • 12
2
votes
1 answer

Clojure parse timestamp to string

I am trying to convert a clojure timestamp to a specific format. I am using the clj-time library. https://github.com/clj-time/clj-time. Here is what I am doing: (f/unparse :year-month-day (t/date-time 2010 10 3)) Which looks a lot like the…
Elie Ladias
  • 111
  • 2
  • 16
2
votes
3 answers

clj-time and displaying in user's time zone

I've been playing around with to-local-date-time, org.joda.time.DateTimeZone/getDefault, formatters, etc. and I still can't figure out how to get a datetime which I've stored as UTC to display in the user's time zone. Some formatters I can get to…
pondermatic
  • 6,453
  • 10
  • 48
  • 63
2
votes
1 answer

Is there an efficient way to group records by day according to a specific time zone?

I’m using a MongoDB database to keep track of analytics for an application. I’m writing a Clojure application (using clj-time and Monger) to get data out of the database. I have a collection containing records like {"_id": ObjectId(...), timestamp:…
bdesham
  • 15,430
  • 13
  • 79
  • 123
1
vote
3 answers

clj-time - how to get local-date from curent time in a different timezone

I'm sitting in the America/Sao_Paulo (or some other random timezone) and now I want to get a LocalDate for the current date in Europe/London. How can I achieve this? (I've got a localDate that I know is in london, and I want to check if it's before…
rutchkiwi
  • 427
  • 3
  • 14
1
vote
1 answer

Passing a parameter into Duckling Clojure function from within Java application

I'm working with wit.ai's Duckling (https://duckling.wit.ai/), however I am depending on and calling Duckling from within my Java application. I have no Clojure experience... I am able to run Duckling's parse method, however I can't figure out how…
Brooks
  • 7,099
  • 6
  • 51
  • 82
1
vote
0 answers

One day difference when persisting to database

My db has a column dob like this: | dob | +------------+ | 1935-06-05 | For TDD I test against an in-memory H2 database using korma and lobos: (:use (lobos [migration :only [defmigration]] core schema config) ( :require [korma.core :as k]…
fbielejec
  • 3,492
  • 4
  • 27
  • 35
1
vote
1 answer

Converting Instant Time into Joda Time in Clojure

I am stuck trying to convert an #inst "2016-08-15T14:00:00.000-00:00" into #object[org.joda.time.DateTime 0x1d4c2099 "2016-08-15T20:47:52.658Z"]. I am trying to do this in order to add (t/minutes duration) to my time/date! Is there a way to convert…
Kwakiekwak
  • 25
  • 3
1
vote
2 answers

Parse string to get date and time in a specific format in Clojure

I just started to play with wit/duckling. It is written in Clojure and I have no previous experience in Clojure. I need to parse a string like 2016-08-14T19:45:48.000+05:30 to a format like 1945hrs, Sunday, August 14th 2016. I searched on Internet…
Saurabh Jain
  • 1,227
  • 1
  • 16
  • 28
1
2