Incorrect UtcOffset to QDateTime::currentDateTimeUtc()

Hey everybody,

I am currently trying to pull the local utc offset to calculate the difference between local time and scheduled events being fired from the outside. I build the events very well and they produce the specific utc offset. However when I create a QDateTime object using QDateTime::currentDateTimeUtc() it gives me a 0 utcOffset (it should be-5). I checked and the time zone on my Dev Alpha device and it is well settled.

Am just missing something? I tried searching the documentation behind the utcOffset() function, but QDateTime documentation on the site of the developers of Cascades does not yet list function utcOffset() (QDateTime). If there is another way to get the information of zone in C++, this would work very well as long as I can get the offset value.

Here's the code I'm using (slightly modified to include only what is rumored)

QDateTime todayDate = QDateTime::currentDateTimeUtc();

//Loop through each item in the input data
for ( QVariantList indexPath = dataModel->first(); !indexPath.isEmpty();
    indexPath = dataModel->after(indexPath) )
{
    //Retrieve the item
    QVariant item = dataModel->data(indexPath);

    QDateTime   startDate       = item.toMap().value("start").toDateTime();

    qDebug() << startDate.utcOffset();
    qDebug() << todayDate.utcOffset();    

}

The result I get in the console is:

Debug: -18000
Debug: 0

The-18000 is OK but the 0 should read also-18000.

Thanks for any help available.

My apologies, it works that you have discovered.

Does that help?

QDateTime current = QDateTime::currentDateTime();
QDateTime currentUTC = current.toUTC ();  QDateTime::currentDateTimeUtc();
QString currentTimeUTCString = currentUTC.toString("yyyyMMddhhmmsszzz");
QDateTime currentUTCConverted = QDateTime::fromString (currentTimeUTCString, "yyyyMMddhhmmsszzz");
diff long = current.toMSecsSinceEpoch () - currentUTCConverted.toMSecsSinceEpoch ();

Tags: BlackBerry Developers

Similar Questions

  • CalendarEvent and zones

    I have a problem to find the right way to create a CalendarEvent in another time zone

    on my Z10 my timezone is: Amsterdam, Berlin + 1 (THIS/MEZ == UTC + 1)

    seems that Z10 uses only the standard time here and not the time of daylight, but the clock is correct on daylight saving time

    also all the timezone - calendar selections are in standard hours - no daylight, leaves so use standard time

    Event-zone: EDT GMT - 05:00

    If I manually enter the event:

    starts: 09:30

    end: 10:00

    Time of the is - 5

    then I get: 15:30-16:00, which is correct to 6 hrs difference

    now, I want to create the CalendarEvent in C++:

    date usinga string as

    T-2013-04 - 03 09:30:00

    also tried: 2013-04 - 03T 09:30:00 - 05:00

    sessionEvent.setStartTime(QDateTime::fromString(dt,Qt::ISODate));)

    and set the time zone:

    sessionEvent.setTimezone ("EAST");

    but the calendar tells me now the event is

    09:30-10:00 my local time

    which is 03:30 - 04:00 IS

    I'm doing something wrong?

    or does mean that I have to add the time zone difference at the date of the event and setStartTime / EndTime at 15:30 - 16:00?

    Now, I have a WORKAROUND

    not flexible for all use cases, but for now it works:

    CalendarEvent sessionEvent;
    sessionEvent.setAccountId(accountId);
    sessionEvent.setFolderId(folderId);
    ...... and so on
    // TODO need the list of Timzone IDs
    // BOSTON, MA belongs to EST / EDT
    // dont use EST or EDT as TimeZone Database ID !
    // Eastern Standard == "America/New_York"
    sessionEvent.setTimezone("America/New_York");
    int offsetDiffInSeconds = 0;
    QString dt;
    // if the device timezone is the same as the event timezone we don't need to calculate !
    if (sessionEvent.timezone() != mCalendarService.settings().currentSystemTimezone()) {
        // we know the offset for the conference in Boston, MA
        // attention! if a conference spans over DST - start/end time, set the offset per conference day
        int eventOffsetInSeconds = -4*60*60; // -04:00 EDT
        // now we need the device offset
        // always calculate new or connect to device time settings changed TODO
        // thx Peter Strange :
        // http://supportforums.blackberry.com/t5/Cascades-Development/Incorrect-utcOffset-from-QDateTime-curre...
        // we need the offset from the conference
        // hint: do this per day if DST is changing while the conference
        dt = "2013-03-26T09:00:00";
        QDateTime eventTime = QDateTime::fromString(dt,Qt::ISODate);
        QDateTime eventTimeUTC = eventTime.toUTC();
        QString eventTimeUTCString = eventTimeUTC.toString("yyyyMMddhhmmsszzz");
        QDateTime eventTimeUTCConverted = QDateTime::fromString(eventTimeUTCString, "yyyyMMddhhmmsszzz");
        int localeOffset = (eventTime.toMSecsSinceEpoch() - eventTimeUTCConverted.toMSecsSinceEpoch()) / 1000;
        // no calculate the offset between locale and event timezone
        offsetDiffInSeconds = localeOffset - eventOffsetInSeconds;
    }
    

    and then, when you set startTime and ednTime for CalendarEvent I calculate time zone schedule event to the local time zone:

    sessionEvent.setStartTime(qdt.addSecs(offsetDiffInSeconds));
    

    so for now, it works, but I really need a list of time zone identifiers of Cascades

    and an easier way to get the diff between 2 zones or available inside the Cascades QTimeZone class

    opens another thread on this

  • SUM IS INCORRECT

    I have a worksheet and the SUM function gives the wrong number. It's really dangerous because I need precision.

    I deduced that there is a single cell, that it fails to include in the sum, even if the cell is selected.

    I click on the cell, I want to add to the column, then press = and then select the column. The sum is incorrect and fails to add one of the cells

    Why?

    It is so irritating and so dangerous that I need clarification on this sheet of numbers. Never had this with excel.

    Help, please!

    Thank you

    without details, it is difficult to guess.

    Often, the cell is not the same as the other somehow.  Maybe it's in text format, or there's a funny character in the cell.  Try to copy the data to a new table in a new document to check the results.

    If you can validate the data, then we can try too.

  • 6 iOS10 incorrect percentage battery iPhone

    On my 6 running latest iOS iPhone 10 (10.0.1) my battery indicator in percentage is incorrect most of the time. I can't tell if the percentage indicator is stuck or something. This happened 9 w/IOS, but seems aggravated with iOS 10. Here are two typical scenarios:

    1. indicator indicates the value > 50%, but then stops

    2. indicator indicates the value ~ 10%, but then when it is plugged in charge indicator of cable past at 30%.

    I see that when people are complaining about this preliminary response was to "upgrade to iOS 9.3 +'-well, which obviously does not work for me." I would like to have an indicator that represents the amount of battery life I have left.

    Bart Taylor wrote:

    On my 6 running latest iOS iPhone 10 (10.0.1) my battery indicator in percentage is incorrect most of the time. I can't tell if the percentage indicator is stuck or something. This happened 9 w/IOS, but seems aggravated with iOS 10. Here are two typical scenarios:

    1. indicator indicates the value > 50%, but then stops

    2. indicator indicates the value ~ 10%, but then when it is plugged in charge indicator of cable past at 30%.

    I see that when people are complaining about this preliminary response was to "upgrade to iOS 9.3 +'-well, which obviously does not work for me." I would like to have an indicator that represents the amount of battery life I have left.

    http://www.Apple.com/batteries/maximizing-performance/

  • Apple maps address and continuous route of incorrect information after four years

    The address of the map and driving directions in IOS devices 3/4 Ave., Almena, WI 54805 continues to be incorrect in Apple Maps to 369 12.  We have presented more than 15 applications over the past 4 years to this fixed and submitted two photos geocoded with delivery address and Barron County, WI property and survey records of SIG showing the right address but this remains unclear.  On an IOS device, if you enter the address 369 12 3/4 Ave., Almena, WI 54805 map will take you to the correct location on the map, but the map shows an address of 369 12 3/4 Ave., Turtle Lake, WI 54889.  And if you have driving directions to 369 12 3/4 Ave., Almena, WI 54805 that will correctly identify the map take you somewhere 369 S 4th Ave, Alpena, MI 49707, 500 miles.

    Apple is not regularly monitor the discussions. These are mostly a user in discussions.

    Send feedback to Apple. They will not respond, but at least know that there is a problem or a suggestion for change. If enough people send feedback, it can get change / suggested the problem solved as soon as possible.

    Your comments

  • My iphone 5 c (IOS 9.3) sent my incorrect position.

    My iphone 5 c (IOS 9.3) sent my incorrect position. I have 'share my location' with my husband and this day there, he checked my position and it showed that I was about 1 to 1 1/2 miles away at a park (I've never been to). I was home at the time and wifi may have been down, but I can't understand why it was closed so far.

    If there is no wifi, cellular service (I have Verizon) would not in the correct location? I even checked the location history on my phone and it me House shows during this period and shows the whole story to that area of the Park? Which would be so far off the coast?

    Thank you.

    If the phone can't get a current location due to the Internet being down, or in the case that the reception is not good enough to triangulate your location using nearby cell towers, the nearest known position will be displayed. If there is a cell tower near this park, it could also be stated as your position until your appliance again to a new location or the quality of the signal is still improving.

  • iPhone app Messages incorrectly reports that the messages are not delivered

    I send text messages with the Messages app on my iPhone.  I've never had a problem until recently.

    Recently, all of my text messages are marked by a red error message "not delivered".  But the beneficiary is in fact receive these messages.

    I want a solution to this problem (if you have one).

    Here are some additional details:

    * I recently made two changes to my iPhone 6, and I wonder if they are related to my problem:

    1. go to iOS 9.3.5

    2 change my cell number

    * I have T-mobile and I "call wifi" enabled.  Usually, I connect using "wifi-calling."

    Hi adaviding,

    Looks like you are having some incorrect Messages notifications appear on your sent messages. Not too sure if recent changes have something to do with it, but I would check your message settings to check everything is in order, it. You can also take a look at the link below. Even if your messages are sent, you can always follow the steps then the message "not delivered" can be resolved. You can also try a simple reboot of your device.

    Restart your iPhone, iPad or iPod touch

    If you can't send or receive messages on your iPhone, iPad or iPod touch

    Please use the Apple Support communities to post your question. These measures should have your Messages app works as expected. Good day.

    Thank you for using

  • Why is my current residence incorrect?

    My current position for various applications is displayed incorrectly. My town is bordered by two other cities. While at home, some applications display my current location as one or the other cities, but never like my own city. Specifically, the maps and the weather app in the Notification of the user.

    Cards

    Maps shows my position as being a little way of streets in one of the neighbouring cities. Is it possible to manually set my current position?

    Weather

    Is there a way to manually set my current position? The weather app shows weather for one of the neighbouring cities like my current position. The city displays includes a very large area of inland and coastal areas in hillside, inner, central regions. Therefore, the displayed temperature is different from my city by 10 degrees every day, or watch troubles when it is sunny outside without a cloud in the sky, etc..

    Is there another way to edit the list of cities and reorganize? Tried to add my city, but the green Add button will not activate. When I click on the 'i' icon, impossible to remove any of the other listed cities or activate the icon 'list' for a city on the list. Change the button only allows me to add or remove items from the category, not to change the content in the weather application.

    Version10.11.6 OS X running on iMac 21.5 inches, end of 2012

    Would appreciate any help.

    Thank you!

    Mac have no GPS radios in them. Then how a Mac running OS X to determine its location? In other words, it cannot on its own. OS X uses to place your WiFi connection to sweep all other routers in the area to try to bring your location. You never have a quite exact location, and it will really change from time to time. As long as you understand it, you can know that your approximate location is sufficient for most applications that rely on location information.

    https://support.Apple.com/en-us/HT204690

    See this link for more information. You cannot manually set your location.

  • iCloud Apple music status is incorrect

    I have about 50 + songs that tend to sync my iPod Classic because they (wrongly) show Apple music iCloud status.

    The songs are all ripped to my own CD or LP/EPs and imported music in iTunes.

    I use two Match iTunes and am a subscriber of Apple's music. My version of iTunes is 12.4.3.1.

    Old bandages show removing the download (song) and the new download should be properly thru, but a test of several different songs give the same incorrect state music Apple iCloud.

    Someone at - there a way to fix this?

    Thank you

    David

    Yes, I had this problem also. I contacted apple support and their engineers reset my library to an end and it solved the problem, but there are a few songs that could not be reset, in which case Apple gave me the credit to buy the song again, and that fixed the issue

    bbEst thing to do is to contact Apple support speak to a Manager or consultant and explain to them and you want to reset your library. You may need to disable iCloud music library while reset happens that it worked for me, it will be useful

  • Hi someone help please I am signing the apple tv correctly and it says the password for itunes that is incorrect. However, I am now connected from my computer and it is OK

    Hi someone help please I am signing the apple tv correctly and it says the password for itunes that is incorrect. However, I am now connected from my computer and it is OK

    Have you tried to reboot your router, correct your location settings, you use audit stage 2.

  • Time Machine of immutable/incorrect information?

    I have a client using 10.11.6 on an iMac with a problem with Time Machine not allowing (at least not not appearing to allow) any changes on the disk used for backup and also showing a date in 2015 on the menu bar which the last backup was performed successfully.  Despite all this the TM backups are up-to-date and occurring normally checked by looking at the TM backup drive that I chose (but which does not appear as the backup selected in parameters of TM drive).

    I tried to delete the file plist TM but don't know where to go next... of ideas?

    Hello MacAttac,

    If I understand you right, you have problems with Time Machine backup on your iMac to clients running 10.11.6. Although it seems to be back up successfully by looking at the drive itself, Time Machine in the menu bar that shows the last backup was actually in 2015, and Time Machine in system preferences shows a different drive than the one that it is backup.  I know the importance of keeping a computer backed up regularly, so I can understand the concern that it would cause if you see incorrect dates for backups of this machines.

    Because this isn't the good drive backup, try following the steps outlined in this support article: If you can not back up or restore your Mac using Time Machine if after you follow these steps, you do not come to a resolution, reply back to us whether these two disks that were used Time Machine on this computer are the same brand and model.

    Thank you for using communities of Apple Support.

    Take care!

  • How to remove email address incorrect autotyped for Amazon signin?

    When I connect to Amazon.com and I start to type in my email address / user ID, the feature 'autotype' indicates an e-mail address incorrect as one of the possibilities (I have created this through an accidental typing error). I have tried everything I can think of to remove this from "autotyped." It doesn't appear when signing into Amazon.com using Firefox (Mac OSX), is not when signing into Amazon.com in using Safari and not when signing into any other account site using also my e-mail address... so, I think it is connected to the Firefox browser and not a matter of preference system Mac or a problem of Amazon.com . Please help me to remove this from "autotyped." Thank you.

    Usually, you can remove the unwanted form autocomplete entries using the keyboard:

    • Start typing until appears undesirable entry
    • Use the down arrow key to select the unwanted entry
    • Press DELETE or shift + delete to delete this entry

    If you want to make a more general cleaning on the form entries, Add - ons are available. For example:

    Form history control
    https://addons.Mozilla.org/firefox/addon/form-history-control/

    There are some recent critics complain that it does not work as well as Lazarus for the recording of the work-in-progress on the forms you fill out currently, but I don't think that there is no complaint regarding its ability to change the saved form history entries.

  • Attempts of incorrect check APPLE ID

    I followed the process what to do when you have changed your Apple ID email address or password - Apple support , but he has asked security questions I don't have answers to.  These responses have been forgotten for a long time because it has been 16 years or more and I did a bad job to go back to update these responses.  Now he says simply ' many incorrect verification attempt"with no other option.  I'm not a recovery email or anything like that.  How can I make this?

    Reset security issues: If you forgot your Apple ID - Apple Support security questions answered

  • Incorrect thumbnails to small size, but OK when viewing is greater

    I imported 38K images in Aperture, and then some pictures of 3-4 K .jpg files, which some have double of those who are already imported.  When I view the photos with thumbnails to the minimum size, some vignettes show a photo which is completely different from the actual picture it represents!  When I increase the size of the thumbnail display, the correct thumbnail is displayed.  I tried to rebuild the Photos DB (Control-Alt on the opening of the Photos), but still the same problem.  Any ideas?

    iMac mid 2011, OSX 10.11.6, 12 GB of RAM.

    Yes - you have a corruption of minor in your library - select a group of up to 100 incorrect thumbnails and twist them and then turn to fix - repeat for all incorrect thumbnails

    How to rebuild the thumbnails in a photo library

    LN

  • Too many attempts of incorrect verification

    I answered the wrong questions in two attempts.

    Later / again changed the questions and answers. To emergency email.

    But whenever I try to enter new responses, this message appears...

    Too many attempts of incorrect verification

    You made too many attempts to answer your security questions. You can try again later or use your rescue email address to reset your security information.

    Please I want a solution to this problem

    Hello

    If you are unable to reset your security questions, you will need to contact the Apple Support.

    The information is available here:

    (I'm afraid that no one here can solve the problem for you.) You don't talk to Apple here - it is a community based on the user).

    More information:

    If you forgot the answers to your questions of security of Apple ID - Apple Support

Maybe you are looking for

  • Need drivers of Windows XP Home for Satellite L30

    Hello I was wondering if someone could help me. I bought a Toshiba Satellite L30 - 10V recently which came with Vista installed and ran incredibly slow. I installed a version of XP on it. Could someone provide me with the XP drivers for this laptop o

  • Get rid of the new Favorites bar

    How to disable or get rid of this favorite bar that appears on the left side of Safari?  Support cat was unable to provide a response and I want it really gone.  I would be grateful to my favorites not being is not in my face of comments when they us

  • Stepper motor control while reading encoder

    Hello I'm looking to generater a pulse train to control a parallel reading and step by step motor in the impulses of the encoder of the motor. I was able to create two distinct VI who perform these taks individually, but when I put them into a single

  • Sound and Audio problems

    When I start my HP 1000-1433TU Notebook PC sound and Audio stops and becomes unable to play videos. How can I get the proper functioning and stay the work as well as the videos become playable? until now the only option that worked to stop the PC and

  • Cannot download Windows 10 because my Windows [7] updates does not work.

    Windows Update fails to download updates. Troubleshooting mentions an error number and does not repair. That's why I can't go to W10