format

How can I convert a timestamp to a user-friendly time string

空扰寡人 提交于 2019-12-06 16:06:28
I want to be able to present "today" and "yesterday" for recent dates in my application. I've got a date formatter in use currently to show dates (retrieved from data records) and will keep using this for anything more than a couple of days old. I just really like the way the SMS app in the iPhone shows dates for recent messages and would like to emulate this. The time-stamps that I have to work with are generated on a server that the phone downloads the data records from. All times are therefore generated at UTC (i.e. GMT) time. I've been fiddling about with this for a while the solutions I

How to delete a section using excel-vba to create a word document

吃可爱长大的小学妹 提交于 2019-12-06 15:30:18
Hello and thank you in advance. I am creating a very complex Word document out of an Excelfile using VBA. It shall be possible to activate something and a text written in a cell shall be transfered to the word document. I got that already done. But if it is not activated the tag "<>" shall be removed, leaving nothing behind. This means that it shall remove not only the text, it shall remove the complete "line". As line might be a section i am not sure if just line is the correct word here. Right now I find and replace them with "" using: With WordDoc.Content.Find .Execute FindText:

Read large txt file in c++

这一生的挚爱 提交于 2019-12-06 14:19:57
问题 I'd like to read a file of about 5MB in memory ... the file has this format (it is a text file) ID 3: 0 itemId.1 0 itemId.2 0 itemId.5 1 itemId.7 ........................ 20 itemId.500 ID 50: 0 itemId.31 0 itemId.2 0 itemId.4 2 itemId.70 ........................ 20 itemId.2120 ..... how can I do this efficiently in c++? 回答1: Reading a file line by line: ifstream fin ("file.txt"); string myStr; while(getline(fin, myStr)) // Always put the read in the while condition. { // Then you only enter

Yii zii.widgets.CDetailView - Output an attribute as HTML code format

你说的曾经没有我的故事 提交于 2019-12-06 12:47:29
问题 I want output attribute description as HTML code in CDetailView. <?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( 'id', 'title', 'description' => array( 'name' => 'description', 'value' => html_entity_decode(CHtml::decode($model->description)), ), 'price', 'date', ), ));?> 回答1: You will want to use the :html format: 'attributes'=>array( 'id', 'title', 'description:html', 'price', 'date', ), For other formats, see CFormatter. You can even extend

RobotFramework - get current Date

旧巷老猫 提交于 2019-12-06 12:47:13
I need to test that the current date is displayed on my device, The date on the device is in format Monday, September 9, 2018 but when i try to test it i can only use the format Monday, 09, 2018 which would fail the test as there is no 0 in the Month date. page should contain element ${DATE} ${DATE_MESSAGE} get current date result_format=%A, %d, %Y element should contain text ${DATE} ${DATE_MESSAGE} How can change the format in robotframework to verify THis format Monday, September 9, 2018. ERROR should have contained text 'Monday, 09, 2018' but its text was 'Monday, September 9, 2018'.

How to format date and time values for SQLite?

雨燕双飞 提交于 2019-12-06 11:58:00
问题 Can't believe I have to ask this here. Even googling didn't help. I want to do this: insert into atable (adatefield,atimefield,adatetimefield) values (A,B,C); adatefield is defined as DATE atimefield is defined as TIME adatetimefield is defined as DATETIME What do I put for A, B and C? It's nice that it's free but the documentation for SQLite is awful. 回答1: A date, time and datetime field will actually all store datetime, it just depends on what you insert into it, and they will all work with

Treating 0 as a significant figure in printf %g format specifier

倾然丶 夕夏残阳落幕 提交于 2019-12-06 11:22:43
I'm trying to print floating point numbers 1.2345678, 0.1234567, 123.45678 using printf in such a way that only the first n characters are printed. I want these number to line up. The %g format specifier in printf("%*g", n, var) does this but the specifier is not treating the 0 in 0.1234567 as a significant figure. This causes the alignment of 0.1234567 to go off wrt to the other two figures. What's the best way to align the numbers in the formats given. Either by treating 0 as significant with %g or using some other method? By definition leading zeros are not significant figures. If you want

windows registry hive files documentation

匆匆过客 提交于 2019-12-06 11:04:50
I need a document that describes format of microsoft windows registry hive file format. The only thing I was able to find is this one http://www.sentinelchicken.com/data/TheWindowsNTRegistryFileFormat.pdf But it has nothing common with the real registry file format. Most of things described here doesn't work at all. For example "Relative offset of next hive bin" is 0 in most of my local files. Pointer to start of last hbin in file points to the middle of hbin. I understand that microsoft doesn't document this, however I know that people are writing parsers for registry files, so I think there

boost log format single attribute with logging::init_from_stream

早过忘川 提交于 2019-12-06 10:53:10
问题 When I set up format params in code, to format date time output I can use something like this logging::formatter simpleFormat(expr::format("%1% %2%") % expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%H:%M:%S") % expr::smessage ); But when I initialize logger with a config file, I can specify format only in attributes position notation, not their format details. so, this line in a boost log config file Format="[%TimeStamp%]: %Message%" produces output: [2015-Feb-06 09:32:27

How retrieve keyword arguments from a string in python?

两盒软妹~` 提交于 2019-12-06 10:50:33
Let's say, I have a string: > my_string = '{foo}/{bar}' > my_string.format(foo='foo', bar='bar') 'foo/bar' Right, cool. But in my case, I want to retrieve which are the keywords arguments in my_string . I have done: > ATTRS_PATTERN = re.compile(r'{(?P<variable>[_a-z][_a-z0-9]*)}') > ATTRS_PATTERN.findall(my_string) ['foo', 'bar'] It's not very sexy. Do you have any better idea ? Chris Clarke Why reinvent the wheel? string.Formatter has the parse() function. >>> import string >>> [a[1] for a in string.Formatter().parse('{foo}/{bar}')] ['foo', 'bar'] You can use the string.Formatter.parse method