IsDayLightSavingTime changed? - vb.net

Before, this code would return True, now it returns False. Have any of you hear of an update on this function?
d2 = New DateTime(2010, 11, 7, 1, 0, 0)
Console.WriteLine("D2: " & System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(d2))
We parse files and put the data into a database, if I parse the exact same file with the same code (it was never changed) I get different results.
Update
This is EST/EDT

Related

How to fix "java.lang.IndexOutOfBoundsException: Index: 1, Size: 1" problem?

I make database with SQLite in Kotlin, and then when i deleted the first data and then i deleted the last data the problem show up.
I've been trying to make id: Int = 0, but still not work
fun deleteCaption(caption: Caption){
val db = this.writableDatabase
// Delete Caption by ID
db.delete(
TABLE_CAPTION,"$COLUMN_CAPTION_ID = ?",
arrayOf(caption.id.toString())
)
db.close()
}
I expect when i deleted the first data and then i deleted the last data it's work but the actual that's no work
IndexOutOfBound means that you are trying to use an element that is too 'far' in the array.
For example, if you have an array of size 3, the possible index are : 0, 1, 2.
So you can't get array[3].
Are you sure your array is not empty ?
Are you removing entries of your array inside a forEach loop on your array ?

Google Sheets API (v4) - `AutoResizeDimensions` not working

I've got a system that generates and automatically maintains lots of spreadsheets on a Drive account.
Whenever I add data to the sheet I run a 'format' method to pass over and make sure everything is ok.
This generally does things like:
set the default font and size across the sheet
set up the heading row
freeze rows
In addition, I have the code below to make sure the first two columns (index 0 and 1) in the sheet are autoresizing to fit their contents. when I run it though, this element doesn't seem to make a difference. The font, column freezes etc all work.
Other notes:
I only want those 2 columns to auto-resize
the amount of rows in a sheet can vary
this job is appended to the end of several in requestList
My code:
requestList.Requests.Add(new Google.Apis.Sheets.v4.Data.Request()
{
AutoResizeDimensions = new AutoResizeDimensionsRequest()
{
Dimensions = new DimensionRange()
{
SheetId = Convert.ToInt32(sheetId),
Dimension = "COLUMNS",
StartIndex = 0,
EndIndex = 1
}
}
});
var updateRequest = sheetService.Spreadsheets.BatchUpdate(requestList, spreadSheetId);
var updateResponse = updateRequest.Execute();
Could the order which I request the 'format' changes be affecting things maybe? Can anyone help?
As written in the documentation,
the start index is inclusive and the end index is exclusive.
So, For the first two columns, it should be
startIndex = 0,
endIndex = 2

How to use If Else in SSRS expression

I am trying to evaluate a text box value using SSSRS expression.
Currently I am doing something like following:
=IIF(Fields!VariableValue.Value =1,"Pass",IIF(Fields!VariableValue.Value = 2,"Fail",IIF(Fields!VariableValue.Value = 3,"Abort",IIF(Fields!VariableValue.Value = 4,"ByPass",IIF(Fields!VariableValue.Value ="#Error","NA",Fields!VariableValue.Value)))))
Is there a better way of doing this?
It's not perfect, but you can use SWITCH to make it a bit easier to read:
=Switch
(
Fields!VariableValue.Value = 1, "Pass",
Fields!VariableValue.Value = 2, "Fail",
Fields!VariableValue.Value = 3, "Abort",
Fields!VariableValue.Value = 4, "ByPass",
Fields!VariableValue.Value = "#Error", "NA"
true, Fields!VariableValue.Value
)
Looking at your example, I'm not 100% sure the original or the new expression will even work (is VariableValue a number or text?) but hopefully this is better way for you.

Split text file into several parts by character

I apologise in advance if there is already an answer to this problem; if so please just link it (I have looked, btw! I just didn't find anything relating to my specific example) :)
I have a text (.txt) file which contains data in the form 1.10.100.0.200 where 1, 10, 100, 0 and 200 are numbers storing the map terrain layout of a game. This file has multiple lines of 1.10.100.0.200 where each line represents an item of terrain in the map.
Here is what I would like to know:
How do I find out how many lines there are, so I know how many items of terrain to create when I read the map file?
What is the method I should use to get each of 1, 10, 100, 0 and 200:
E.g. when I am translating the file into a map terrain at runtime I might use the terrainitem1.Location = New Point(x, y) or terrainitem1.Size = New Size(p, q) commands, where x, y, p and q are integers or doubles relating to the terrain's location or size. Where would I then find x, y etc. out of 1, 10, 100, 0 and 200, if say x is equal to 1, y to 10 and so on?
I am sorry if this isn't clear, please just ask me and I'll try to explain.
N.B. I am using VB.NET WinForms
There is no way to know how many lines a file has without opening the file and reading its contents.
You didn't indicate how far you've got on this. Do you know how to open a file?
Here's some basic code to do what you want. (Sorry, this is C# but the idea is the same in VB.)
string line;
using (TextReader reader = File.OpenText(#"C:\filename.txt"))
{
// Read each line from the file (until null returned)
while ((line = myTextReader.ReadLine()) != null)
{
// Get each number in line (as string)
string[] values = line.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
// Convert each number to integer
id = int.Parse(values[0]);
height = int.Parse(values[1]);
width = int.Parse(values[2]);
x = int.Parse(values[3]);
y = int.Parse(values[4]);
}
}

Why is iTextSharp reading pages 1..N instead of N?

Here's my code:
var sb = new StringBuilder();
var st = new SimpleTextExtractionStrategy();
string raw;
using(var r = new iTextSharp.text.pdf.PdfReader(path)) {
for(int pn = 1; pn <= r.NumberOfPages; pn++) {
raw = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(r, pn, st);
sb.Append(raw);
}
}
This works for almost all PDFs I've run across... until today:
http://www7.dleg.state.mi.us/orr/Files/AdminCode/356_10334_AdminCode.pdf
For this PDF (and others like it on the same site), the extracted text for page 1 is correct, but the text for page 2 contains pages 1 and 2, page 3 contains pages 1-3, etc. So my StringBuilder ends up with the text from pages 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, etc.
Using the default Location-based strategy has the same issue (and won't work for these particular PDFs anyway).
I recently upgraded from a much older version of iTextSharp (5.1-ish?) and didn't experience this issue before (I believe I've parsed some of these files before without issue). I poked through the source and didn't see anything obvious.
I thought I could work around this by asking for only the last page, but this doesn't work -- I get only the last page. If I hard-code the loop to get pages 2..4, I get 2, 2, 3, 2, 3, 4. So the issue may be some sort of data that PdfReader is maintaining between calls to GetTextFromPage.
Change your code to something like this:
var sb = new StringBuilder();
string raw;
using(var r = new iTextSharp.text.pdf.PdfReader(path)) {
for(int pn = 1; pn <= r.NumberOfPages; pn++) {
var st = new SimpleTextExtractionStrategy();
raw = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(r, pn, st);
sb.Append(raw);
}
}
Update based on mkl's comment: a strategy remembers all page content it has been confronted with. Thus, you have to use a fresh strategy if you want an extraction with nothing buffered yet.