w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
iOS NSDateformatter issue - dateFromString returning same (incorrect) time regardless of input string
Well there is a small mistake in your date formate, you are not handeling the date offset (timezone). NSDateFormatter will not pick the latest found time as the time not the timezone. In your code yyyy-MM-dd'T'HH:mm:ss+HH:mm you are parsing the time twice, you should use yyyy-MM-dd'T'HH:mm:ssZZZZ. the ZZZZspecifies the time zone. Be aware that this code will only work on iOS6 and higher, if you need support for iOS 5 you should remove the : from the timezone.

Categories : IOS

Deleting rows of daylight saving time from a time indexed pandas dataframe
The problem is that drop takes an array-like argument labels, and you are only passing it a timestamp. You should be able to use a list comprehension instead of your loop too: indices = [pd.Timestamp(DSTvalue) for DSTValue in hrsDSTadjust if DSTvalue in df.index] df = df.drop(indices)

Categories : Python

JavaScript Time Zone is wrong for past Daylight Saving Time transition rules
I have confirmed that this is a true bug in JavaScript. Tested with common US time zones that follow daylight saving time Eastern, Central, Mountain, Pacific Tested in Chrome, Firefox, Safari and failed (latest versions) Tested in IE 6, 7, 8, 9 and failed. Tested in IE 10 and passed (not affected). Tested on Windows 7, 8 and Mac OSX. This is pretty troubling. Does anyone know the root cause? I thought it might be a WebKit bug, but Firefox uses Gecko. I checked various issue lists and couldn't find this particular problem anywhere. Perhaps I missed something. I'm not sure where to file a bug report, since it affects multiple places. Perhaps it is a core JavaScript bug? I really find it hard to believe that something this basic has been overlooked by a unit test. I thought perha

Categories : Javascript

Daylight saving time in .net
You will need to know the specific time zone you are talking about. Australia has 5 major time zones, and 13 discrete entries in the TZDB. You can read more here. For the conversion, use TimeZoneInfo, or Noda Time. You should also read the timezone tag wiki. If you can be more specific, and show code for what you have tried, I will update this answer with a more detailed response.

Categories : Dotnet

Daylight saving time in java
Joda time might be able to solve your problem: http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTimeZone.html

Categories : Java

Make Rails ignore daylight saving time when displaying a date
Create a helper that utilizes the dst? method on TimeZone to check whether the passed timezone is currently in DST. If it is, then subtract an hour from the supplied DateTime instance: # helper function module TimeConversion def no_dst(datetime, timezone) Time.zone = timezone if Time.zone.now.dst? return datetime - 1.hour end return datetime end end Then, render the adjusted (or non-adjusted) time in your view: # in your view <%= no_dst(DateTime.parse("2013-08-26T00:00:00Z"), 'Eastern Time (US & Canada)') %> #=> Sun, 25 Aug 2013 19:00:00 EDT -04:00

Categories : Ruby On Rails

php convert local time to utc time taking into consideration Daylight savings
You can get UTC time with gmdate: http://php.net/manual/en/function.gmdate.php Also you can change your timezone to UTC: date_default_timezone_set('UTC');

Categories : PHP

How do I set a joda LocalDateTime object to a specified time with current and local daylight savings and time zone information in java
A LocalDateTime doesn't logically have any time zone or DST information. That's the whole point - it's "local" but not to any specific time zone. Two people in different time zones might both wake up at the same local date/time, but that doesn't mean they're the same instants. If you need a type which includes a time zone, you should be using DateTime. EDIT: Okay, one approach is to take "today in the local time zone", parse the time to a LocalTime, combine the two to form a LocalDateTime, convert that to a DateTime in UTC, then convert that DateTime to the local time zone instead. The difficulty is that the end dates may not be the same, in which case you may need to add or subtract a day. That could then change the time of day due to DST changes, which makes it harder still. There are

Categories : Java

db.Time Property saving time as datetime instead of just time
I'm not sure why you have two inline assignments, but to get time out of a timedelta object: >>> b datetime.datetime(2013, 7, 15, 10, 21, 31, 599402) >>> a datetime.datetime(2013, 7, 15, 10, 18, 11, 251477) >>> str(b-a) '0:03:20.347925' >>> (datetime.datetime.min + (b-a)).time() datetime.time(0, 3, 20, 347925) In order to store only the time, you need to use TimeProperty in your datastore. It will be represented internally as datetime, but will store datetime.time() objects.

Categories : Python

UIActionSheet displays normal the first time, incorrect the second time
Well, the crux of the biscuit (as it were) had to do with the self.window code in the application didFinishLaunchingWithOptions method. Once I switched this app over to set the window's root view controller instead of adding a view controller's view as a subview of the window, it started behaving much better. Once again, I should probably read my own blog once in a while... http://www.dosomethinghere.com/2012/09/24/the-app-delegates-uiwindow-is-finicky/

Categories : IOS

Daylight savings time with mysql and php
use date_default_timezone_set('UTC'); (you might want to take a look at the php manual)

Categories : PHP

NSDateFormatter time zone abbreviation
according to http://www.openradar.me/9944011, Apple updated the ICU library which NSDateFormatter depends on, some time during the Lion/iOS 5 era. and it no longer handles most 3-letter timezones like "MSK" in particular (Moscow Time) because they're ambiguous, they only are used if the "cu" flag is set for the locale. Which means that you get to handle it. For example with this: NSString *threeLetterZone = [[dateString componentsSeparatedByString:@" "] objectAtIndex:4]; NSTimeZone *timeZone = [NSTimeZone timeZoneWithAbbreviation:threeLetterZone]; if (timeZone) { NSString *gmtTime = [dateString stringByReplacingOccurrencesOfString:threeLetterZone withString:@"GMT"]; date = [[pivotalDateFormatter dateFromString:gmtTime] dateByAddingTimeInterval:-timeZone.seco

Categories : IOS

Rails ignore daylight savings time
Rails is going to convert your dates/times to the application configured timezone or the user timezone (assuming you have setup some sort of filter to use the user.timezone); and this WILL include manipulation based on DST. You will need to override this behavior and there are probably a couple of options: Look into using Time.dst? in order to subtract / add time to whatever is being pulled out of the database Look into using skip_time_zone_conversion_for_attributes within AR and do the conversion yourself via virtual attributes Store the time as something other than a date/time; possibly as a separate field from the date in just a normal string format

Categories : Ruby On Rails

Manipulating times logically with respects to daylight savings time
It sort of depends on your semantics. If you are interested in what the local time might be in exactly half a day, then yes: you convert to UTC, add half a day, and convert back to local time. On the other hand, if you operate primarily on local times (we do this in electricity load forecasting, for example), you might go the other way, ie 'how many hours away is our half-day future event?': you treat the local time as if it were UTC, add half a day, then treat that as a local time and convert back to UTC to do sanity checks - you have to be aware that some local times don't exist, and some local times are ambiguous.

Categories : C++

Simple form format a time field to show '21:30' instead of entire UTC time string
You can add attr_accessor to your model (for example formatted_time) and use this field for get fromatted time and set it. Before save you can parse value of @formatted_time and apply it to time_of_event field.

Categories : Ruby On Rails

Rails 3.1 Test Whether a Time Object is inside a String Time Range
Let's simplify your problem and see if we can set you on the right path. time_open evaluates to the following value: >> time_open = Time.use_zone('UTC'){Time.zone.parse '2000-01-01 ' + "8:00AM"} => Sat, 01 Jan 2000 08:00:00 UTC +00:00 Let's convert client1.sched_start (I refer to this as scheduled_time) to a Time object (this step might not be necessary if client1.sched_start is already a Time object, check with client1.sched_start.class). >> scheduled_time = Time.parse('2000-01-01 07:30:00 UTC') => 2000-01-01 07:30:00 UTC time_open and scheduled_time are not equal: >> time_open == scheduled_time => false If we compare time_open to the same time, it will be equal: >> correct_start = Time.parse('2000-01-01 08:00:00 UTC') => 2000-01-01 08:00:00

Categories : Ruby On Rails

Generate a random string at compile time or run time and use it in the rest of the program
import System.Random main = do gen <- newStdGen let str = take 10 $ randomRs ('a','z') gen putStrLn str putStrLn $ (reverse . (take 3)) str This generates a string ten characters long with only lowercase letters. This code is in the IO monad but str is pure it can be passed to pure functions. You can't get something random without the IO Monad. You could do an unsafePerformIO but I don't really see why. You can pass the str value around if you always want the same one. If you look at the last line of my code you can see i have a pure function that operates on the string but since i want to see it i call putStrLn which returns an empty IO action. EDIT: Or this may be the place for the Reader Monad

Categories : Haskell

Convert the time string received from server to local time
you have to parse the String returned by the server with SimpeDateFormat: SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("EST")); Date date = simpleDateFormat.parse("2013-06-19 00:13:21"); TimeZone destTz = TimeZone.getTimeZone("yourtimezone"); simpleDateFormat.setTimeZone(destTz); String result = simpleDateFormat.format(date);

Categories : Android

Is split() of a static string a run-time or compile-time operation?
You can view bytecode using the dis module: >>> from dis import dis >>> >>> def f(): ... words = 'fee fi fo fum'.split() ... >>> dis(f) 2 0 LOAD_CONST 1 ('fee fi fo fum') 3 LOAD_ATTR 0 (split) 6 CALL_FUNCTION 0 9 STORE_FAST 0 (words) 12 LOAD_CONST 0 (None) 15 RETURN_VALUE split (as loaded by LOAD_ATTR) is called via CALL_FUNCTION and its result is assigned to words via STORE_FAST at runtime. In other words, x.split() is not resolved at compile-time, even if x is a hardcoded string. Of course, the performance difference between using 'fee fi fo fum'.split() and its result, namely ['fee', 'fi', 'fo',

Categories : Python

"Incorrect string value" error in MySql when saving Unicode
I think this works for you, try and let me know if it works: import MySQLdb as mdb con = mdb.connect('host', 'user', 'pass', 'dbname') cur = con.cursor() con.set_character_set('utf8') cur.execute('SET NAMES utf8;') cur.execute('SET CHARACTER SET utf8;') cur.execute('SET character_set_connection=utf8;')

Categories : Python

Compile time string assignment for run-time identification
Everything you do here is fine. Templates would get you nothing because you still need to store a runtime pointer in the base class for dynamic identification. Smart pointers would get you nothing because the lifetime of the string is the entire program. If you aren't computing anything, char const * and initialization from a string literal are ideal. If you are computing the string, then you can use static std::string const wrapped in a getter function. class Derived : public Base { public: Derived() : Base(get_name()) {} private: static std::string const & get_name() { static std::string const name = "Derived"; // or = compute_name(); return name; } }; This avoids the static initialization order fiasco. (The getter function receives an extra multithre

Categories : C++

Parsing String Time Format (NOT Time Zones)
I'm glad to hear you have an answer that you think will help you out. But before you write too much code, revisit this assertion you made: ...there is no way to make the form field (Google Forms, limited customizability) anything other than plain-text Here's how you define a question to present a Date & Time picker, using the Forms UI. The spreadsheet that is receiving your form responses will end up with a Date object - no need to mess around with strings at all.

Categories : Javascript

Populating text box with string date-time without the time
You have ToShortDateString along with all possible formats you can supply to ToString method.

Categories : C#

Saving tweets in MySql throws "Incorrect string value: 'xF0x9Fx92xB2xF0x9F"
Try changing your column's charset to the value reflecting the charset of the strings you want to insert. Example: ALTER TABLE database.table MODIFY COLUMN col VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

Categories : Mysql

change time string of HH:mm am/pm to 24 hour time
Using moment.js: moment(string, 'h:mm a').format('H:mm'); If you want to do it manually, this would be my solution: function to24Hour(str) { var tokens = /([10]?d):([0-5]d) ([ap]m)/i.exec(str); if (tokens == null) { return null; } if (tokens[3].toLowerCase() === 'pm' && tokens[1] !== '12') { tokens[1] = '' + (12 + (+tokens[1])); } else if (tokens[3].toLowerCase() === 'am' && tokens[1] === '12') { tokens[1] = '00'; } return tokens[1] + ':' + tokens[2]; } The manual solution is harder to understand, is less flexible, is missing some error checking and needs unit tests. In general, you should usually prefer a well-tested popular library's solution, rather than your own (if a well-tested library is available).

Categories : Javascript

DateTime String to Date, In Time and Out Time
Here is the SQLFiddel Demo Below is the Query select NIP, Nama, DATE_FORMAT(Date_Time, '%Y-%m-%d') as date, Case Min(Date_Time) When Max(Date_Time) Then '' Else DATE_FORMAT(Date_Time, '%H:%i:%s') End as InTime, DATE_FORMAT(max(Date_Time), '%H:%i:%s') as OutTime from Attd Group By NIP, Nama, DATE_FORMAT(Date_Time, '%Y-%m-%d')

Categories : Mysql

Get only time data out of date and time string.
Assuming you could access the "date" as a string: >>> from datetime import datetime >>> time_string = "[15/Apr/2013:23:55:00 +0530]" >>> format = "[%d/%b/%Y:%H:%M:%S %z]" >>> dt = datetime.strptime(time_string, format) >>> dt datetime.datetime(2013, 4, 15, 23, 55, tzinfo=datetime.timezone(datetime.timedelta(0, 19800))) # Accessing the time as an object: >>> the_time = dt.time() >>> the_time datetime.time(23, 55) # Accessing the time as a string: >>> the_time.strftime("%H:%M:%S") '23:55:00' If you are positively definitively absolutely certain the date has a fixed format, you could just slice your string: >>> time_string = "[15/Apr/2013:23:55:00 +0530]" >>> time_string[-15:-7] '23:55:00' Th

Categories : Python

Spring MVC Daylight saving issue
I want to know, how come spring mvc form submission getting EST whereas my application is EDT You're using the America/New_York time zone, which alternates between EST and EDT as daylight saving time changes occur. When you use a time without a date, you're implying the date of 1/1/1970 - which for America/New_York was in EST at that time. You should instead be applying the time to a particular date so it will use the correct offset for that time.

Categories : Java

Does PHP timezone observe Daylight Saving?
How can I detect day light savings automaticaly in PHP? echo date('I', time()); The I (capital i) is a 1/0 denoting whether or not daylight saving is currently in effect. http://php.net/manual/en/function.date.php hope it helps. However if you need to know if a specific timezone WILL observe Daylight savings, someone has made a function here: How to tell if a timezone observes daylight saving at any time of the year?

Categories : PHP

Translating time stamps (start, end) into time series data. Errors with align.time() and colnames
This is not an answer to your problem. Honestly it is not clear for me the transition between the data you show in the image and the example of your data. It seems like that you can't reproduce this data. So Here a function to generate a reproducible example of your data. I think it can be at least useful, to validate your model. function to sample data library(reshape2) start.min <- as.POSIXct("2013-01-01 00:00:00 PST") hours.min <- format(seq(start.min, length.out=24*60, by = "mins"), '%H:%M') ## function to generate a trip sample ## min.dur : minimal duration of a trip ## max.dur : maximal duration of a trip ## min.trip : minimal number of trips that a user can do gen.Trip <- function(min.dur=3,max.dur=10,min.trip=100){ ## gen

Categories : R

Display UTC time incorrect after 12am
Change this line var currentHours = currentTime.getUTCHours() + 8; to this EDIT: var currentHours = (currentTime.getUTCHours() + 8) % 24; When the UTC time in hours becomes lets say 19 hours, then your currentHours variable becomes 27 hours instead of 3 hours which is why the problem occurs. "Moddin" it solves the problem.

Categories : Javascript

Incorrect date/time parameter
date -d expects one string, but gets multiple arguments. For the timestamp to be treated as a single string, you need to add quotes. myapp | xargs -I% date -d "%"

Categories : Linux

NSDate Time MST incorrect when comparing
It seems you are doing notably extra work in constructing an 'adjusted' date string. Specifically, you start with a string, you extract some components from the current time, you add some components (one of which, the day, may be causing your problem), and then you parse the date. Perhaps this is more direct: NSDateFormatter *dateFormatter = [NSDateFormatter new]; [dateFormatter setDateFormat: @"h:mma"]; [dateFormatter setDefaultDate: [NSDate new]]; [dateFormatter setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @"MST"]]; // Notice use of setDefaultDate: and the setDateFormat: argument // Now parse your two date strings (one shown) in your original format NSString *timeOne = @"7:00AM"; NSDate *dateOne = [dateFormatter dateFromString: timeOne]; // Do the compariso

Categories : IOS

identify the row in my time vector where the time is 5 seconds before the last printed time, times are however in milliseconds
For your sample vector (let's call it t): find(t < t(end) - 5000, 1, 'last') ans = 4 For the full matrix, it's almost the same thing: find(matrix(:,2) < matrix(end,2) - 5000, 1, 'last')

Categories : Matlab

.NET/JavaScript ignores daylight saving (DST) when parsing ISO8601
DateTime.Parse by default "converts" the time component to the Local kind of the current thread's current culture info. That is not the same as the hour offset you currently have, because "summer time" depends on whether it is summer or not. The string "1987-01-05T08:45:30.500+0100" always parses to the same DateTime instance when your culture is en-GB. That does not depend on whether it is summer time or not when the code runs. Also see my answer in the thread you link.

Categories : Javascript

How to compare Starting time and End time of a event with existing events of same time on same day?
You can use 24 hour format to solve this in your logic. you have to save existing event timings in Database. whenever new event timings entered, you need to compare with existing both start & end timings with previous ones. For Example: Event1: x1 to y1 Event2; x2 to y2 if(x2==x1 && y2==y1) if(x2>x1 &&x2<y1) andif(y2<y1) ...so on based on your requirement.

Categories : Asp Net

Does Javascript Date.getHours() include daylight saving times?
Yes. From the Mozilla website: getHours Returns the hour (0-23) in the specified date according to local time. Clearly "local time" includes DST. And just to be sure, in the Chrome JS Console... new Date() Sat Aug 03 2013 22:40:23 GMT+0200 (ora legale Europa occidentale) new Date().getHours() 22 I live in Italy... Here it's 22:40... And we are under DST (in winter Italy is GMT+0100)

Categories : Javascript

PHP date_default_timezone_set() Resulting In Incorrect Time For Africa/Lagos
The timezones database in PHP got deprecated. The best thing you can do is upgrade PHP to the latest 5.3. Apart from up-to-date timezones you'll get all the latest security fixes - the version 5.3.10 is pretty old and there were quite a few security issues fixed. Unfortunately it's impossible to update only timezones db in PHP on Windows, as it's compiled into the binary files.

Categories : PHP

Data truncation-Incorrect date value when trying to insert a time
Use %H insteadd of %h %H uses 24 hour format wherein %h uses 12 Hour format INSERT INTO tblData_FY14 VALUES (STR_TO_DATE('24/07/2013','%d/%m/%Y'), STR_TO_DATE('14:31:07','%H:%i:%s'), STR_TO_DATE('14:31:20','%H:%i:%s'), 1, 1, 2, 3, 4, 13)

Categories : Android

LINQ to Entities- Time difference in Hours coming incorrect
Your original code is dividing by 3600, which truncates the fractional hours you get when dividing by 3600: you need to use 3600.0 instead. We can then wrap with a deliberate truncation using EntityFunctions.Truncate to get the nice 2 digit format. Also not sure why you need an IQueryable<dynamic> here. var qry = s.Videos .GroupBy(v => new { v.Name }) .Select(g => new { g.Key.Name, TotalVideoHours = EntityFunctions.Truncate(g.Sum(c => SqlFunctions.DateDiff("s", c.RecordingStarted, c.RecordingEnded) / 3600.0), 2) });

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.