Search Results

Search found 571 results on 23 pages for 'timezone'.

Page 7/23 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • How to control Time zone formatting in System.Xml.Serialization or during application execution?

    - by Beal
    I'm developing a C# .Net Application that is executing on a system located in the Central Time Zone. The application gets information from a third party using an API they provide. I have used the WSDL to produce the code that my application access the API with...their reporting API allows you to define a start date and end date for the report. These are C# DateTime fields and XSD:dateTime. Now when I set the start date and end dates and allow the API to create the SOAP messages the dates don't always include a Time Zone unless I set the date fields using the ToLocalTime method; however, the method will create the DateTime fields in the Central Time Zone (CST) but I need to have it create these fields in the Pacific Time Zone (PST). If I set my machine time to PST all is good...but of course that causes other time issues. What methods can I use to control the formatting of the DateTime? Alternatively, is there a application setting that can be set in C# that allows timezone control?

    Read the article

  • How to: get Date, Time and Time zone from single DateTimePicker Control

    - by Vijay
    Hi All, I am developing an application in which I am trying to fetch Date, Time and Time Zone from single DateTimePicker control. Can anybody help to resolve this? Thanks in advance. EditV1: I am using .net framework 2.0. Now I am able to fetch Date and Time with Single DateTimepicker by setting its CustomFormat property as; dtpicker2.CustomFormat = "MM/dd/yyyy,hh:mm:ss" Now my problem is to fetch TimeZone. EditV2: Now here is one more issue, if I set DateTimePicker's format property to Time, it shows me something like 2:30:00 PM. I am storing this in a file and reasigning it to the DateTimePicker control. Can anybody help me out, how to achieve this?

    Read the article

  • How to store and compare time-zone sensitive times

    - by Chad Moran
    I have a data structure where an entity has times stored as an int (minutes into the day) for fast comparison. The entity also has a Foreign Key reference back to a TimeZone table which contains the .NET CLR ID Name and it's Standard Time/Daylight Time acronyms. Since this information is stored as time-zone insensitive - I was wondering how in LINQ to SQL I could convert this into a UTC DateTime for comparison against other times that will be in UTC. Just to be clear this conversion has to be done server-side so that I can execute filtering on the SQL Server and not the client. I am using .NET 3.5 SP1 and SQL Server 2008.

    Read the article

  • Why does Java return a date in GMT-4.5 when choosing Co-ordinated Universal Time time zone in Window

    - by Simon Nickerson
    We have seen a strange issue on some Windows XP machines involving the "Co-ordinated Universal Time" time zone. Not all Windows XP machines seem to have it, but on those that do, the following simple Java program public class TimeTest { public static void main(String[] args) { System.out.println(java.util.TimeZone.getDefault()); System.out.println(new java.util.Date()); } } on JDK 1.6.0_06 prints: sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null] Fri Nov 13 05:34:14 VET 2009 (i.e. 4 and a half hours behind GMT). I should add that I am based in London, and have never been to South America. :-) My questions are: Where does Java get this time zone from? I thought Co-ordinated Universal Time was supposed to be the new name for GMT. Why do some Windows machines have this time zone but not others?

    Read the article

  • Changing set_timezone does not always take effect

    - by LearneR
    I have two table table-1 id date-time ----------------------- 1 2012-12-13 15:20:13 table-2 id date-time ----------------------- 1 2012-12-13 15:20:13 Now i am selecting the record with mysql set_timezone function Case-1 SET time_zone='+00:00'; SELECT `date-time` FROM `table-1`; // 2012-12-13 09:50:13 Case-2 SET time_zone='+00:00'; SELECT `date-time` FROM `table-2`; // 2012-12-13 15:20:13 ---Not converting to specified timezone In case-1 it's giving converted date-time, but not in Case-2. What would be the issue?

    Read the article

  • Java date long value changed after insert, select query

    - by StackExploded
    AFAIK, java Date type is independent from Timezone which means that it represents specific moment of time as long typed value. I found really weird thing here. This is the original value i tried to insert. (http-0.0.0.0-9080-4) 1352955600000 <-- long integer. (http-0.0.0.0-9080-4) Thu Nov 15 00:00:00 EST 2012 <-- User Friendly Format. After i finished inserting into Oracle 11g database, the value has changed! (http-0.0.0.0-9080-4) 1352952000000 (http-0.0.0.0-9080-4) Wed Nov 14 23:00:00 EST 2012 How could this happen?? The more weird thing is it only happens specific environments such as Jboss. I'm currently using below environments. java 1.6 ibatis 2.34 jboss-5.1 (server) tomcat 6.0 (local) oracle 11g Is there anybody who can give me a clue or link to be helpful? it really bugging me!!

    Read the article

  • Dealing with Time Zones

    - by RavIncredible
    Hi All, I need some guidance with one of my project requirements, I am developing an application which has to deal with various time zones. Scenario: User 1 is from India, so his time zone would be GMT+05:30 User 2 is from UK, so his time zone would be GMT+01:00 If the User 1 sends a message to User 2, I want to show the Message Sent/Received Time as per the user’s time zone. For example User 1 sends a message at 6:30 Indian time, when User 2 would view the message it would show as 2:00 UK time. Here goes my question, whenever I save the message should I convert it to GMT+00, so all my base times stamps are the same and then later when I display the message, I convert it back to User specific time zone. Would this be complex? Is this the best way of doing this? I like to get views for both saving and displaying, also when I should do the time conversion from optimization point of view. I would need do deal with any/all timezones. I am developing this application with PHP and MySQL and I am aware of timezone conversion method come with both PHP and MySQL. I am just trying to figure out the best way of doing this. Look forward to have all valuable suggestions. Note : As of now I am not much worried with day/light savings. Thanks Ravi

    Read the article

  • Google App Engine, parsedatetime and TimeZones

    - by Ron
    Hey guys, I'm working on a Google App Engine / Django app and I encountered the following problem: In my html I have an input for time. The input is free text - the user types "in 1 hour" or "tomorrow at 11am". The text is then sent to the server in AJAX, which parses it using this python library: http://code.google.com/p/parsedatetime/. Once parsed, the server returns an epoch timestamp of the time. Here is the problem - Google App Engine always runs on UTC. Therefore, lets say that the local time is now 11am and the UTC time is 2am. When I send "now" to the server it will return "2am", which is good because I want the date to be received in UTC time. When I send "in 1 hour" the server will return "3am" which is good, again. However, when I send "at noon" the server will return "12pm" because it thinks that I'm talking about noon UTC - but really I need it to return 3am, which is noon for the request sender.. I can pass on the TZ of the browser that sends the request, but that wont really help me - the parsedatetime library wont take a timezone argument (correct me if I'm wrong). Is there a walk around this? Maybe setting the environments TZ somehow? Thanks!

    Read the article

  • Time Zone on WebLogic Server

    - by adejuanc
    In order to configure the time zone with WebLogic Server, use the following JVM startup command: -Duser.timezone=<timezone> For example, in the java arguments in the admin console at Environments -> Servers -> Servername -> - Server Start tab, configure the startup settings that Node Manager will use to start the particular server. For example: -Duser.timezone='America/Arizona' There are many different time zones, each with its own code. For a complete list please refer to : http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones For testing, you can run the following code on WLS with a JSP, servlet, or deploying the class: import java.util.Calendar; import java.util.TimeZone; public class TestTimeZone {  public static void main(String[] args) {    Calendar calendar = Calendar.getInstance();    TimeZone timeZone = calendar.getTimeZone();    System.out.println(" your Current TimeZone is : " + timeZone.getDisplayName());    System.out.println(" Time Zone id : "+ timeZone.getID());  } }

    Read the article

  • How can I simply change the Timezone Offset with Zend_Date?

    - by Nicky Hajal
    I'm using Zend_Date to manage dates/times in a scheduling app. The only way I'm able to determine the user's Timezone is via Javascript which only gives a Timezone Offset. Zend_Date only seems to take Timezones in the 'America/New_York' format. Is there a way to get the users timezone in this format or set the Timezone Offset with Zend_Date? Thanks!

    Read the article

  • Generating a drop down list of timezones with PHP

    - by Xeoncross
    Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need help knowing which of these would be the best to attempt to use when trying to get the UTC offset from the user on register. One: <option value="-12">[UTC - 12] Baker Island Time</option> <option value="-11">[UTC - 11] Niue Time, Samoa Standard Time</option> <option value="-10">[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time</option> <option value="-9.5">[UTC - 9:30] Marquesas Islands Time</option> <option value="-9">[UTC - 9] Alaska Standard Time, Gambier Island Time</option> <option value="-8">[UTC - 8] Pacific Standard Time</option> <option value="-7">[UTC - 7] Mountain Standard Time</option> <option value="-6">[UTC - 6] Central Standard Time</option> <option value="-5">[UTC - 5] Eastern Standard Time</option> <option value="-4.5">[UTC - 4:30] Venezuelan Standard Time</option> <option value="-4">[UTC - 4] Atlantic Standard Time</option> <option value="-3.5">[UTC - 3:30] Newfoundland Standard Time</option> <option value="-3">[UTC - 3] Amazon Standard Time, Central Greenland Time</option> <option value="-2">[UTC - 2] Fernando de Noronha Time, South Georgia &amp; the South Sandwich Islands Time</option> <option value="-1">[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time</option> <option value="0" selected="selected">[UTC] Western European Time, Greenwich Mean Time</option> <option value="1">[UTC + 1] Central European Time, West African Time</option> <option value="2">[UTC + 2] Eastern European Time, Central African Time</option> <option value="3">[UTC + 3] Moscow Standard Time, Eastern African Time</option> <option value="3.5">[UTC + 3:30] Iran Standard Time</option> <option value="4">[UTC + 4] Gulf Standard Time, Samara Standard Time</option> <option value="4.5">[UTC + 4:30] Afghanistan Time</option> <option value="5">[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time</option> <option value="5.5">[UTC + 5:30] Indian Standard Time, Sri Lanka Time</option> <option value="5.75">[UTC + 5:45] Nepal Time</option> <option value="6">[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time</option> <option value="6.5">[UTC + 6:30] Cocos Islands Time, Myanmar Time</option> <option value="7">[UTC + 7] Indochina Time, Krasnoyarsk Standard Time</option> <option value="8">[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time</option> <option value="8.75">[UTC + 8:45] Southeastern Western Australia Standard Time</option> <option value="9">[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time</option> <option value="9.5">[UTC + 9:30] Australian Central Standard Time</option> <option value="10">[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time</option> <option value="10.5">[UTC + 10:30] Lord Howe Standard Time</option> <option value="11">[UTC + 11] Solomon Island Time, Magadan Standard Time</option> <option value="11.5">[UTC + 11:30] Norfolk Island Time</option> <option value="12">[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time</option> <option value="12.75">[UTC + 12:45] Chatham Islands Time</option> <option value="13">[UTC + 13] Tonga Time, Phoenix Islands Time</option> <option value="14">[UTC + 14] Line Island Time</option> Or using PHP friendly values: <option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option> <option value="America/Adak">(GMT-10:00) Hawaii-Aleutian</option> <option value="Etc/GMT+10">(GMT-10:00) Hawaii</option> <option value="Pacific/Marquesas">(GMT-09:30) Marquesas Islands</option> <option value="Pacific/Gambier">(GMT-09:00) Gambier Islands</option> <option value="America/Anchorage">(GMT-09:00) Alaska</option> <option value="America/Ensenada">(GMT-08:00) Tijuana, Baja California</option> <option value="Etc/GMT+8">(GMT-08:00) Pitcairn Islands</option> <option value="America/Los_Angeles">(GMT-08:00) Pacific Time (US & Canada)</option> <option value="America/Denver">(GMT-07:00) Mountain Time (US & Canada)</option> <option value="America/Chihuahua">(GMT-07:00) Chihuahua, La Paz, Mazatlan</option> <option value="America/Dawson_Creek">(GMT-07:00) Arizona</option> <option value="America/Belize">(GMT-06:00) Saskatchewan, Central America</option> <option value="America/Cancun">(GMT-06:00) Guadalajara, Mexico City, Monterrey</option> <option value="Chile/EasterIsland">(GMT-06:00) Easter Island</option> <option value="America/Chicago">(GMT-06:00) Central Time (US & Canada)</option> <option value="America/New_York">(GMT-05:00) Eastern Time (US & Canada)</option> <option value="America/Havana">(GMT-05:00) Cuba</option> <option value="America/Bogota">(GMT-05:00) Bogota, Lima, Quito, Rio Branco</option> <option value="America/Caracas">(GMT-04:30) Caracas</option> <option value="America/Santiago">(GMT-04:00) Santiago</option> <option value="America/La_Paz">(GMT-04:00) La Paz</option> <option value="Atlantic/Stanley">(GMT-04:00) Faukland Islands</option> <option value="America/Campo_Grande">(GMT-04:00) Brazil</option> <option value="America/Goose_Bay">(GMT-04:00) Atlantic Time (Goose Bay)</option> <option value="America/Glace_Bay">(GMT-04:00) Atlantic Time (Canada)</option> <option value="America/St_Johns">(GMT-03:30) Newfoundland</option> <option value="America/Araguaina">(GMT-03:00) UTC-3</option> <option value="America/Montevideo">(GMT-03:00) Montevideo</option> <option value="America/Miquelon">(GMT-03:00) Miquelon, St. Pierre</option> <option value="America/Godthab">(GMT-03:00) Greenland</option> <option value="America/Argentina/Buenos_Aires">(GMT-03:00) Buenos Aires</option> <option value="America/Sao_Paulo">(GMT-03:00) Brasilia</option> <option value="America/Noronha">(GMT-02:00) Mid-Atlantic</option> <option value="Atlantic/Cape_Verde">(GMT-01:00) Cape Verde Is.</option> <option value="Atlantic/Azores">(GMT-01:00) Azores</option> <option value="Europe/Belfast">(GMT) Greenwich Mean Time : Belfast</option> <option value="Europe/Dublin">(GMT) Greenwich Mean Time : Dublin</option> <option value="Europe/Lisbon">(GMT) Greenwich Mean Time : Lisbon</option> <option value="Europe/London">(GMT) Greenwich Mean Time : London</option> <option value="Africa/Abidjan">(GMT) Monrovia, Reykjavik</option> <option value="Europe/Amsterdam">(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option> <option value="Europe/Belgrade">(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option> <option value="Europe/Brussels">(GMT+01:00) Brussels, Copenhagen, Madrid, Paris</option> <option value="Africa/Algiers">(GMT+01:00) West Central Africa</option> <option value="Africa/Windhoek">(GMT+01:00) Windhoek</option> <option value="Asia/Beirut">(GMT+02:00) Beirut</option> <option value="Africa/Cairo">(GMT+02:00) Cairo</option> <option value="Asia/Gaza">(GMT+02:00) Gaza</option> <option value="Africa/Blantyre">(GMT+02:00) Harare, Pretoria</option> <option value="Asia/Jerusalem">(GMT+02:00) Jerusalem</option> <option value="Europe/Minsk">(GMT+02:00) Minsk</option> <option value="Asia/Damascus">(GMT+02:00) Syria</option> <option value="Europe/Moscow">(GMT+03:00) Moscow, St. Petersburg, Volgograd</option> <option value="Africa/Addis_Ababa">(GMT+03:00) Nairobi</option> <option value="Asia/Tehran">(GMT+03:30) Tehran</option> <option value="Asia/Dubai">(GMT+04:00) Abu Dhabi, Muscat</option> <option value="Asia/Yerevan">(GMT+04:00) Yerevan</option> <option value="Asia/Kabul">(GMT+04:30) Kabul</option> <option value="Asia/Yekaterinburg">(GMT+05:00) Ekaterinburg</option> <option value="Asia/Tashkent">(GMT+05:00) Tashkent</option> <option value="Asia/Kolkata">(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi</option> <option value="Asia/Katmandu">(GMT+05:45) Kathmandu</option> <option value="Asia/Dhaka">(GMT+06:00) Astana, Dhaka</option> <option value="Asia/Novosibirsk">(GMT+06:00) Novosibirsk</option> <option value="Asia/Rangoon">(GMT+06:30) Yangon (Rangoon)</option> <option value="Asia/Bangkok">(GMT+07:00) Bangkok, Hanoi, Jakarta</option> <option value="Asia/Krasnoyarsk">(GMT+07:00) Krasnoyarsk</option> <option value="Asia/Hong_Kong">(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option> <option value="Asia/Irkutsk">(GMT+08:00) Irkutsk, Ulaan Bataar</option> <option value="Australia/Perth">(GMT+08:00) Perth</option> <option value="Australia/Eucla">(GMT+08:45) Eucla</option> <option value="Asia/Tokyo">(GMT+09:00) Osaka, Sapporo, Tokyo</option> <option value="Asia/Seoul">(GMT+09:00) Seoul</option> <option value="Asia/Yakutsk">(GMT+09:00) Yakutsk</option> <option value="Australia/Adelaide">(GMT+09:30) Adelaide</option> <option value="Australia/Darwin">(GMT+09:30) Darwin</option> <option value="Australia/Brisbane">(GMT+10:00) Brisbane</option> <option value="Australia/Hobart">(GMT+10:00) Hobart</option> <option value="Asia/Vladivostok">(GMT+10:00) Vladivostok</option> <option value="Australia/Lord_Howe">(GMT+10:30) Lord Howe Island</option> <option value="Etc/GMT-11">(GMT+11:00) Solomon Is., New Caledonia</option> <option value="Asia/Magadan">(GMT+11:00) Magadan</option> <option value="Pacific/Norfolk">(GMT+11:30) Norfolk Island</option> <option value="Asia/Anadyr">(GMT+12:00) Anadyr, Kamchatka</option> <option value="Pacific/Auckland">(GMT+12:00) Auckland, Wellington</option> <option value="Etc/GMT-12">(GMT+12:00) Fiji, Kamchatka, Marshall Is.</option> <option value="Pacific/Chatham">(GMT+12:45) Chatham Islands</option> <option value="Pacific/Tongatapu">(GMT+13:00) Nuku'alofa</option> <option value="Pacific/Kiritimati">(GMT+14:00) Kiritimati</option> Or just using PHP it's self $timezones = DateTimeZone::listAbbreviations(); $cities = array(); foreach( $timezones as $key => $zones ) { foreach( $zones as $id => $zone ) { /** * Only get timezones explicitely not part of "Others". * @see http://www.php.net/manual/en/timezones.others.php */ if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $zone['timezone_id'] ) && $zone['timezone_id']) { $cities[$zone['timezone_id']][] = $key; } } } // For each city, have a comma separated list of all possible timezones for that city. foreach( $cities as $key => $value ) $cities[$key] = join( ', ', $value); // Only keep one city (the first and also most important) for each set of possibilities. $cities = array_unique( $cities ); // Sort by area/city name. ksort( $cities ); It seems like the last one would be the safest as it would grow with the PHP release being used. You could also flip that array around when needed to tie timezones to city names.

    Read the article

  • Does salesforce.com have a timezone field that is DST aware?

    - by vfilby
    I am mailing out reminders to potential customers and the time is getting converted to our servers timezone EST (I think it is currently using EDT though as appropriate). I need to store the timezone for the potential customer and translate the time into their current timezone. I can store the offset but I am worried about daylight savings time. I can always store a non-DST offset but that causes issues when the signup appointment is scheduled before DST but occurs after DST. Ideally I would like to store a timezone and have salesforce translate the datetime to that timezone accounting for DST if necessary. How can I do this?

    Read the article

  • heroku time zone problem

    - by Ole Morten Amundsen
    Why does Time.now yield the server local time when I have set the another time zone in my environment.rb config.time_zone = 'Copenhagen' I've put this in a view <p> Time.zone <%= Time.zone %> </p> <p> Time.now <%= Time.now %> </p> <p> Time.now.utc <%= Time.now.utc %> </p> <p> Time.zone.now <%= Time.zone.now %> </p> <p> Time.zone.today <%= Time.zone.today %> </p> rendering this result on my app at heroku Time.zone (GMT+01:00) Copenhagen Time.now Mon Apr 26 08:28:21 -0700 2010 Time.now.utc Mon Apr 26 15:28:21 UTC 2010 Time.zone.now 2010-04-26 17:28:21 +0200 Time.zone.today 2010-04-26 Time.zone.now yields the correct result. Do I have to switch from Time.now to Time.zone.now, everywhere? Seems cumbersome. I truly don't care what the local time of the server is, it's giving me loads of trouble due to extensive use of Time.now. Am I misunderstanding anything fundamental here?

    Read the article

  • TimeZoneInfo to TIME_ZONE_INFORMATION structure

    - by jaircazarin-old-account
    Hey, I've a TimeZoneInfo object and from this one I want to create a TIME_ZONE_INFO struct. Bias, StandardDate and Daylightdate are pretty easy to obtain. However, I'm having problems getting standardbias and daylightbias. So the question is, How can I get the standardbias from a TimeZOneInfo object and how can I get the same thing for daylightbias (there is a AdjustmentRule.DaylightDelta, but as you can see I need the offset not the delta). Thanks.

    Read the article

  • Convert UTC DateTime to another Time Zone

    - by Mark Richman
    I have a UTC DateTime value coming from a database record. I also have a user-specified time zone (an instance of TimeZoneInfo). How do I convert that UTC DateTime to the user's local time zone? Also, how do I determine if the user-specified time zone is currently observing DST? I'm using .NET 3.5. Thanks, Mark

    Read the article

  • Find UTC Offset given a city

    - by soccerfan
    In C++ on Windows, given a city, lets say london or newyork or sydney or singapore etc.. how do I find the UTC offset for each of them, ie the function should be able to accept a city name and return the UTC offset in the current scenario ie taking into account daylight savings. Any ideas how this can be done using win32 APIs

    Read the article

  • heroku time zone problem, logging local server time

    - by Ole Morten Amundsen
    UPDATE: Ok, I didn't formulate a good Q to be answered. I still struggle with heroku being on -07:00 UTC and I at +02:200 UTC. Q: How do I get the log written in the correct Time.zone ? The 9 hours difference, heroku (us west) - norway, is distracting to work with. I get this in my production.log (using heroku logs): Processing ProductionController#create to xml (for 81.26.51.35 at 2010-04-28 23:00:12) [POST] How do I get it to write 2010-04-29 08:00:12 +02:00 GMT ? Note that I'm running at heroku and cannot set the server time myself, as one could do at your amazon EC2 servers. Below is my previous question, I'll leave it be as it holds some interesting information about time and zones. Why does Time.now yield the server local time when I have set the another time zone in my environment.rb config.time_zone = 'Copenhagen' I've put this in a view <p> Time.zone <%= Time.zone %> </p> <p> Time.now <%= Time.now %> </p> <p> Time.now.utc <%= Time.now.utc %> </p> <p> Time.zone.now <%= Time.zone.now %> </p> <p> Time.zone.today <%= Time.zone.today %> </p> rendering this result on my app at heroku Time.zone (GMT+01:00) Copenhagen Time.now Mon Apr 26 08:28:21 -0700 2010 Time.now.utc Mon Apr 26 15:28:21 UTC 2010 Time.zone.now 2010-04-26 17:28:21 +0200 Time.zone.today 2010-04-26 Time.zone.now yields the correct result. Do I have to switch from Time.now to Time.zone.now, everywhere? Seems cumbersome. I truly don't care what the local time of the server is, it's giving me loads of trouble due to extensive use of Time.now. Am I misunderstanding anything fundamental here?

    Read the article

  • Guessing the time zone from an arbitrary "location" string?

    - by Thomas
    I'm trying to run some statistics over the Stack Overflow data dump, and for that I would like to know the time zone for each user. However, all I have to go on is the completely free-form "location" string. I'll stress that I'm only looking for an approximation of the time zone; of course, in general this is an unsolvable problem. However, many people fill out their country, state and/or city, which should give a pretty good indication. It's okay if it fails for other cases. It doesn't have to be reliable, it doesn't have to be accurate, it doesn't have to cover all bases. I don't want to waste too much time on this, so I'm wondering if there is some code out there that can make a reasonable guess. Any language, platform, API or library goes. Any ideas?

    Read the article

  • Occasional Date or timezone discrepancy in hudson or maven with jodatime

    - by TheStijn
    hi, I hope following explanation will make sense because it's a weird problem we're facing and hard to describe. We have a maven project which gets build in hudson and that contains some unit tests where dates are used and asserted. The hudson server runs on solaris. Now, occasionally (like 30% of the times) the unit tests using dates fail because 3,5 hours are deducted from the specified time in the unit test and hence asserts start failing. The other 70% everything works fine although nothing at all changed in the code and we run the hudson job several times an hour. I add following code to a unittest to check the time: @Test public void testDate() { System.out.println("new DateMidnight(2011, 1, 5).toDate();"); System.out.println(new DateMidnight(2011, 1, 5).toDate()); System.out.println(new DateMidnight(2011, 1, 5).toDate().getTime()); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DAY_OF_MONTH, 5); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); System.out.println("cal.getTime();"); System.out.println(cal.getTime()); System.out.println(cal.getTime().getTime()); } So basically it should print the same thing when using jodatime or plain old Calendar. This is the case in 70% of the runs; for the other 30% I get following printouts: Running TestSuite new DateMidnight(2011, 1, 5).toDate(); Tue Jan 04 21:30:00 MET 2011 1294173000000 cal.getTime(); Wed Jan 05 12:00:00 MET 2011 1294225200000 Local maven tests never appear the pose this problem and we can't figure out what could be the cause of it. Especially, we can't think of a single reason why the tests sometimes pass and sometimes fail without changing any code nor hudson or server setting. Also, we run the maven install with cobertura which means that the unit tests are run twice. It happens also that they pass the first time and fail the second time or the other way around or that they fail both times. Thanks for any help, Stijn

    Read the article

  • Adding time zone hours difference to time

    - by Hwang
    I know there's a much better and correct way to do it, but i need a temporarily solutions. I need to add in extra hours to the time, and the day will change automatically too. How should I change the code below? package { public class getTime { private var today:Date=new Date(); private var hour:uint=today.getHours(); private var minute:uint=today.getMinutes(); private var month:uint=today.getMonth(); private var monthArray:Array=new Array('January','February','March','April','May','June','July','August','September','October','November','December'); private var time:String = getUSClockTime(today.getHours(), today.getMinutes()); public var dateNtime:String=(time+", " +today.getDate()+" "+monthArray[month]+" "+today.getFullYear());; public function getTime() { } private function getUSClockTime(hrs:uint, mins:uint):String { var modifier:String="PM"; var minLabel:String=doubleDigitFormat(mins); if (hrs>12) { hrs=hrs-12; } else if (hrs == 0) { modifier="AM"; hrs=12; } else if (hrs < 12) { modifier="AM"; } return (doubleDigitFormat(hrs) + ":" + minLabel + " " + modifier); } private function doubleDigitFormat(num):String { if (num<10) { return ("0" + num); } return num; } } }

    Read the article

  • understand SimpleTimeZone and DST Test

    - by Cygnusx1
    I Have an issue with the use of SimpleTimeZone class in Java. First, the JavaDoc is nice but not quite easy to understand in regards of the start and end Rules. But with the help of some example found on the web, i managed to get it right (i still don't understand why 8 represents the second week of a month in day_of_month!!! but whatever) Now i have written a simple Junit test to validate what i understand: package test; import static org.junit.Assert.assertEquals; import java.sql.Timestamp; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.SimpleTimeZone; import org.apache.log4j.Logger; import org.junit.Test; public class SimpleTimeZoneTest { Logger log = Logger.getLogger(SimpleTimeZoneTest.class); @Test public void testTimeZoneWithDST() throws Exception { Calendar testDateEndOut = new GregorianCalendar(2012, Calendar.NOVEMBER, 4, 01, 59, 59); Calendar testDateEndIn = new GregorianCalendar(2012, Calendar.NOVEMBER, 4, 02, 00, 00); Calendar testDateStartOut = new GregorianCalendar(2012, Calendar.MARCH, 11, 01, 59, 59); Calendar testDateStartIn = new GregorianCalendar(2012, Calendar.MARCH, 11, 02, 00, 00); SimpleTimeZone est = new SimpleTimeZone(-5 * 60 * 60 * 1000, "EST"); est.setStartRule(Calendar.MARCH, 8, -Calendar.SUNDAY, 2 * 60 * 60 * 1000); est.setEndRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar theCal = new GregorianCalendar(est); theCal.setTimeInMillis(testDateEndOut.getTimeInMillis()); log.info(" Cal date = " + new Timestamp(theCal.getTimeInMillis()) + " : " + theCal.getTimeZone().getDisplayName()); log.info(" Cal use DST = " + theCal.getTimeZone().useDaylightTime()); log.info(" Cal In DST = " + theCal.getTimeZone().inDaylightTime(theCal.getTime())); log.info("offset = " + theCal.getTimeZone().getOffset(theCal.getTimeInMillis())); log.info("DTS offset= " + theCal.getTimeZone().getDSTSavings()); assertEquals("End date Should be In DST", true, theCal.getTimeZone().inDaylightTime(theCal.getTime())); theCal.setTimeInMillis(testDateEndIn.getTimeInMillis()); log.info(" Cal date = " + new Timestamp(theCal.getTimeInMillis()) + " : " + theCal.getTimeZone().getDisplayName()); log.info(" Cal use DST = " + theCal.getTimeZone().useDaylightTime()); log.info(" Cal In DST = " + theCal.getTimeZone().inDaylightTime(theCal.getTime())); log.info("offset = " + theCal.getTimeZone().getOffset(theCal.getTimeInMillis())); log.info("DTS offset= " + theCal.getTimeZone().getDSTSavings()); assertEquals("End date Should be Out DST", false, theCal.getTimeZone().inDaylightTime(theCal.getTime())); theCal.setTimeInMillis(testDateStartIn.getTimeInMillis()); log.info(" Cal date = " + new Timestamp(theCal.getTimeInMillis()) + " : " + theCal.getTimeZone().getDisplayName()); log.info(" Cal use DST = " + theCal.getTimeZone().useDaylightTime()); log.info(" Cal In DST = " + theCal.getTimeZone().inDaylightTime(theCal.getTime())); log.info("offset = " + theCal.getTimeZone().getOffset(theCal.getTimeInMillis())); log.info("DTS offset= " + theCal.getTimeZone().getDSTSavings()); assertEquals("Start date Should be in DST", true, theCal.getTimeZone().inDaylightTime(theCal.getTime())); theCal.setTimeInMillis(testDateStartOut.getTimeInMillis()); log.info(" Cal date = " + new Timestamp(theCal.getTimeInMillis()) + " : " + theCal.getTimeZone().getDisplayName()); log.info(" Cal use DST = " + theCal.getTimeZone().useDaylightTime()); log.info(" Cal In DST = " + theCal.getTimeZone().inDaylightTime(theCal.getTime())); log.info("offset = " + theCal.getTimeZone().getOffset(theCal.getTimeInMillis())); log.info("DTS offset= " + theCal.getTimeZone().getDSTSavings()); assertEquals("Start date Should be Out DST", false, theCal.getTimeZone().inDaylightTime(theCal.getTime())); } } Ok, i want to test the date limits to see if the inDaylightTime return the right thing! So, my rules are : DST start the second sunday of March at 2am DST end the first sunday of november at 2am In 2012 (now) this give us the march 11 at 2am and November 4 at 2am You can see my test dates are set properly!!! Well here is the output of my test run: 2012-11-01 18:22:44,344 INFO [test.SimpleTimeZoneTest] - < Cal date = 2012-11-04 01:59:59.0 : Eastern Standard Time> 2012-11-01 18:22:44,345 INFO [test.SimpleTimeZoneTest] - < Cal use DST = true> 2012-11-01 18:22:44,345 INFO [test.SimpleTimeZoneTest] - < Cal In DST = false> 2012-11-01 18:22:44,345 INFO [test.SimpleTimeZoneTest] - <offset = -18000000> 2012-11-01 18:22:44,345 INFO [test.SimpleTimeZoneTest] - <DTS offset= 3600000> My first assert just fails and tell me that 2012-11-04 01:59:59 is not inDST... !!!!??? If i put 2012-11-04 00:59:59, the test pass! This 1 hour gap just puzzle me... can anyone explain this behavior? Oh, btw, if anyone could elaborate on the : est.setStartRule(Calendar.MARCH, 8, -Calendar.SUNDAY, 2 * 60 * 60 * 1000); Why 8 means second week of march... and the -SUNDAY. I can't figure out this thing on a real calendar example!!! Thanks

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >