Questions tagged [localtime]

Calendar time expressed relative to the user's local timezone.

Calendar time expressed relative to the user's local timezone.

461 questions
2
votes
1 answer

Timezone issue with Joda-time when converting a LocalTime to a DateTime using .toDateTime()

I am writing some code to do periodic scheduling based based on time of day. I am representing the regular schedule time of day as a Joda LocalTime object. I then create event instances by converting the LocalTime to a DateTime. When initially…
Matt King
  • 118
  • 1
  • 6
2
votes
5 answers

Unix time as int to local time

I have a function which returns a timestamp in unix time as int. I need to convert this int to a string dd/mm/yy in local time. The "local" part is causing me problems, if it weren't for that, I could have just made my own function to convert it. I…
user129186
  • 1,156
  • 2
  • 14
  • 30
2
votes
2 answers

How to convert boost local_date_time to time_t

I have: time_t dataFromTodayByAddingYearsMonthsDays(int years, int months, int days) { using namespace boost::local_time; local_date_time local = local_sec_clock::local_time(time_zone_ptr()); local +=…
meaning-matters
  • 21,929
  • 10
  • 82
  • 142
2
votes
4 answers

Segfault when using time.h

Ok I've been trying just about everything I know to get this program to stop crashing, but I just can't see why. I was able to isolate the problem to code with ctime, and just made a small program to demonstrate what's wrong. This code compiles…
2
votes
2 answers

localtime() crashing with segmentation fault in c

Have a bit of trouble tracking down the cause of this. Here is the code bit: #include time_t now; struct tm *mytime; char yyyy[5]; char mm[3]; char dd[3]; char mname[10]; if(time(&now)!=(time_t)(-1)) { mytime=localtime(&now); …
Mannix
  • 411
  • 10
  • 23
2
votes
2 answers

A thread-safe version of the standard C function 'localtime'

I am using localtime in a multi-threaded application. I have to replace it with a thread-safe version, which to my understanding is called localtime_r. However, when I do so, I am unable to complete the build, due to a linkage failure. I am not even…
barak manos
  • 29,648
  • 10
  • 62
  • 114
2
votes
1 answer

Create jodatime LocalDate from java.sql.Time

I'm new to joda-time and I didn't find anywhere examples to do some simple things. I want to make an object where to save a time value read from a table in a database (a java.sql.Time - e.g. "18:30:00") I don't care about time zone, so I think that…
True Soft
  • 8,675
  • 6
  • 54
  • 83
2
votes
1 answer

localtime and asctime are unsafe, but the safe functions don't have the same parameters

I'm attempting to create timestamps for my program. On my sister's Mac (using Xcode 4.2) this code works perfectly fine: struct tm * timeInfo; time_t rawtime; time (&rawtime); timeInfo = localtime (&rawtime); string…
Wenzel745
  • 73
  • 2
  • 11
2
votes
2 answers

C - error storing time_t variable in a struct [time.h]

I'm working on building a process scheduler that follows the FIFO algorithm. I've written all the code and it is working, except for the part of the report. Here an example of how the report is coming out: FIFO PROCESS SCHEDULER Simulation # Report:…
linuxunil
  • 313
  • 2
  • 14
2
votes
3 answers

Perl epoch time before 1970 formatting

I have problem formatting and dealing with dates before the epoch 1/1/1970 in Perl, dates comes back as negative integer: my $time=timelocal(0, 0, 0, 1, 1, 1969); print "$time\n"; $theTime = localtime($time); print "the time is good:…
daliaessam
  • 1,636
  • 2
  • 21
  • 43
2
votes
1 answer

Is there a signal safe alternative to localtime_r()?

We've got some code to do crawl the stack, and it's very handy to be able to dump the current time when we do so. Unfortunately, while the localtime_r() function is reentrant, it is not signal safe, and we see it calling internal pthread mutex…
Peeter Joot
  • 7,848
  • 7
  • 48
  • 82
1
vote
2 answers

Perl localtime error

I get the epoch time at February 28th 2009, then add to it the number of seconds in a week. But then I get March 4th instead of March 7th. Why? The following is the code: #!/usr/bin/perl use POSIX; my $hours_per_day = 24; my $hours_per_week …
john-jones
  • 7,490
  • 18
  • 53
  • 86
1
vote
1 answer

Javascript GMT string convert to Local Time

$(function() { $('#datepicker').datepick({ multiSelect: 999, monthsToShow: 3, minDate: new Date(), maxDate: '+1y', showTrigger: '#calImg', dateFormat: 'yy-mm-dd', …
marcom
  • 13
  • 1
  • 4
1
vote
0 answers

Timezone conversions for DateTime in Ruby 1.8.6

(Stuck in Ruby 1.8.6 land) Until recently I was using Time to parse UTC dates and print them in a local timezone dt = Time.parse("20111225080000Z") puts dt.localtime Sun Dec 25 21:00:00 +1300 2011 puts dt.zone "New Zealand Daylight…
Paul
  • 13
  • 3
1
vote
1 answer

Parse a datetime string that has no 'T' separator using java.time

I am trying to parse string "2023-05-10 09:41:00" to LocalTime using java.time library. When I try LocalTime.parse("2023-05-10 09:41:00", DateTimeFormatter.ISO_LOCAL_DATE_TIME) I get java.time.format.DateTimeParseException. However when I try…
mars8
  • 770
  • 1
  • 11
  • 25