I have an application that writes to another application and needs to provide the date + timezone of the system. I have been using strftime with the %z argument to get the timezone, and it has been working very well on Linux. However, last week we decided to merge it to solaris just to find out that %z is not present.
Someone suggested...
Through profiling I've discovered that the sprintf here takes a long time. Is there a better performing alternative that still handles the leading zeros in the y/m/d h/m/s fields?
SYSTEMTIME sysTime;
GetLocalTime( &sysTime );
char buf[80];
for (int i = 0; i < 100000; i++)
{
sprintf(buf, "%4d-%02d-%02d %02d:%02d:%02d",
sysTime.wYear...
I'm getting the compiler error: (83) error: improper pointer/integer combination: arg #1.
Here's the code that is doing it:
char boot_time[BUFSIZ];
...
Line 83:
strftime(boot_time, sizeof(boot_time), "%b %e %H:%M", localtime(table[0].time));
where table is a struct and time is a time_t member.
I read that "improper pointer/integ...
I want to format a date object so that I can display strings such as "3rd July" or "1st October". I can't find an option in Date.strftime to generate the "rd" and "st". Any one know how to do this?
...
so I have to insert a bunch of records from a data source that has dates in the format
Sun, Sep 13 1:00 PM.
I'm just going to execute SQL that uses
STR_TO_DATE
But I was wondering in case I need it in the future if you guys know of a way to do this using a ruby method...like a reverse strftime
...
I'm trying to find an easy way to build forms which show dates in the Australian format (dd/mm/yyyy). This was the only way I could find to do it. It seems like there should be a better solution.
Things to note:
Created a new widget which renders date value in dd/mm/yyyy format
Created new date field to prepend the locate date for...
In /initializers/time_formats.rb I have this:
Time::DATE_FORMATS[:profile] = "%m / %d / %Y"
However this obviously produces dates such as: 09 / 08 / 2001
Google tells me my best bet is to use some kind of gsub regular expression to edit out the 0's. Is this true or is there a better alternative?
...
Here's the sort of time formatting I'm after:
2009-10-08 04:31:33.918700000 -0500
I'm currently using this:
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", ts);
Which gives:
2009-10-11 13:42:57 CDT
Which is close, but not exact. I can't seem to find anything on displaying '-0500' at the end. Plus I'm getting the seconds as an int.
...
I didn't realize this, but apparently Python's strftime function doesn't support dates before 1900:
>>> from datetime import datetime
>>> d = datetime(1899, 1, 1)
>>> d.strftime('%Y-%m-%d')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year=1899 is before 1900; the datetime strftime() methods requi...
i want to be get a date (the current hour) from strftime and get it into a nsstring in obj-c for the iphone-os
...
Is it possible to apply strftime formatting to the value of a text input field using a Rails text_field helper?
In the form I use for creating or editing a record, I have a text input field which is populated by a variant of the calendardateselect javascript. I click the text field and a little calendar pops up. After I select year, mont...
I have one page and it's encoding is UTF-8 and If i try to run that code in unix system everythings looks fine but when i try to run in windows(7) some chracters looks question mark(�). How can run the code fine both of two system(without using iconv).
header('Content-Type: text/html; charset=UTF-8');
setlocale(LC_ALL, 'turkish');
echo ...
I'm trying to convert a string "20091229050936" into "05:09 29 December 2009 (UTC)"
>>>import time
>>>s = time.strptime("20091229050936", "%Y%m%d%H%M%S")
>>>print s.strftime('%H:%M %d %B %Y (UTC)')
gives
AttributeError: 'time.struct_time' object has no attribute 'strftime'
clearly, I've made a mistake: time is wrong, it's a datetime ...
We have a C++/MFC application which allows users to customize date formatting via configuration files. Not wanting to reinvent the wheel, I pass the format string to CTime::Format("< format string >") to do the actual formatting. Under the covers, Format calls a variant of the standard C function strftime().
Naturally, the user can ac...
I need to read the column value of the following query
SELECT strtime('%Y-%m', created_at) as field FROM table GROUP BY field
the type of column field is 3 (I assume it is blog), but I need string
How should I?
Updated
const char* sql =
"SELECT CAST(strftime('%Y', created_at) as INTEGER) as year FROM table GROUP BY year
i...
I am currently learning the zsh and now I wanted to use strftime but i get:
zsh: command not found: strftime
I think I'm doin' something wrong, since I see people using that function all the time in their dotfiles.
...
My "task" database table look like this:
[title] [content] [start_date] [end_date]
[...] [...] [01.06.2010 20:10:36] [06.06.2010 20:10:36]
[...] [...] [05.06.2010 20:10:36] [06.06.2010 20:10:36]
And I want to find only those records that meet the condition that a given day is between start_date and end_date.
I've tried the following ...
Okay, I really know this has GOT to be the long way around doing this... however, what I want is relatively simple one would think. I have a database with a timestamp column. I am using iPhone SDK with SQLite3. I want to have SQLite3 get all records for today (where timestamp >= midnight this morning) ..
What i have come up with (th...
Is there any way to obtain Unix Time with nanoseconds with strftime in bash?
My line for unix time :
<command> | awk '{ print strftime("%s"), $0; }'
I cannot use date +%N because date is only evaluated once.
Is there any work around?
...
I have an sqlite database which currently holds an integer field called Year which currently only stores the year. In future versions I want to store a full date and time.
I updated my table to include a FullDate field using alter table.
> ALTER TABLE Files ADD COLUMN UploadDate DATETIME DEFAULT 0;
Next, I want to migrate all the ex...