Home Application – Time Calculator (TimeCalc) for Nokia N9/N950 – MeeGo Harmattan

# Application – Time Calculator (TimeCalc) for Nokia N9/N950 – MeeGo Harmattan

Below Developer Amanda Lam takes us through her latest application Time Calculator (TimeCalc):
How many days from now until December 21st 2012? How old am I in number of days? If I stop eating now for World Vision 30 Hour Famine, when shall I be able to start eating again?
Time Calculator (TimeCalc) is a little handy tool to answer all these types of questions! You can add/subtract a number of years, months, days, hours, minutes, or seconds to/from a date/time value. You can also find out the difference between two date/time values.
Key Features

• Add / subtract a number of years, months, days, hours, minutes, or seconds to / from a date / time value.
• Find out the difference between two date/time values.

• Support decimal and negative values, and Simplified / Traditional Chinese localisation.

Assumptions.
According to the definition of the Gregorian calendar, the following assumptions are made in this application:

• 1 Year = 365.25 days
• 1 Month = 30.436875 days
• 1 Week = 7 days
• 1 Day = 24 hours
• 1 Business Day = A day in between Monday and Friday inclusive, except local public holidays.
• (Future support of customising local public holidays may be added.)
• 1 Hour = 60 Minutes
• 1 Minute = 60 Seconds
• Earliest date supported: 4713/01/02 B.C. (i.e. the next day of the Julian Day)
• Earliest Selectable Date: 1900/01/01 00:00:00
• Latest Selectable Date: 2099/12/31 23:59:59
• Largest Plus / Minus Value: 99999
• A.D. 2012 – 2012 years = 1 B.C., as there is no Year 0 by definition

Notice.
Calculation results of this application are for reference purpose only; their accuracy is not guaranteed.
You can now download the stable version of this app from the Nokia Store at your N9 by searching the keyword TimeCalc.
Source Code
I have created a project at Nokia Developer Projects site where you can find the source code of this app:
https://projects.developer.nokia.com/timecalc
Developer’s Sidenote
This app is entirely developed in QML and JavaScript. Here are some findings while I was developing this app, which might be useful to you if you’re messing up with similar controls / constraints:

• The date and time selection dialogs (DatePickerDialog and TimePickerDialog) are extra components provided by Qt Quick 1.1 for Symbian and MeeGo 1.2 Harmattan. To use these components, you need the following declarations:

Code:
```import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.0```

The maximumYear and miniYear attributes define the selection scope of the year. The default value of maximumYear attribute is current year + 20 years, and the default value of the minimumYear attribute is the current year. If you specify a very large scope, say minimumYear = 0 and maximumYear = 2999, it will take quite a bit of time to load the component and hence the year. To take a balance in between performance and practicality (I guess this is still adequate enough for some years in the future? Assuming the Judgment Day will not come too soon… ), the earliest selectable year of this app is defined as 1900 and the latest selectable year is defined as 2099.

• Most date and time calculations make use of the native date and time functions provided by the QML JavaScript engine. The weird thing is, only the QML JavaScript engine has a lowest day limit, which is the next day of Julian Day (why Julian Day, and why the next day of it?!). The WebKit2 / JavaScript engine of the N9’s native browser, as well as all the major desktop browsers (IE, Firefox, Chrome, Safari and Opera), all don’t have such limit.
• When QML JavaScript engine handles 2-digit years, it will be treated as 19XX. For example, year “12” will be treated as “1912”. Even when you specify x = new Date(2012-2000,1,1,0,0,0,0), the value of x you get get will be 1912/1/1. However, most desktop major browsers would also be using this kind of assumption (smells like Y2K-related issues?). In this app, I have to handle these cases specifically.
• I have made use of the localisation features provided by Qt and Qt Linguist to create UI localisations for English, Traditional Chinese and Simplified Chinese. However, the menu items in the SelectionDialog component cannot be localised directly using qsTr() or QT_TR_NOOP(). You will have to prepare a JavaScript function that creates the menu items for the ListModel to be used by the SelectionDialog component, and then call this JavaScript function during the Component.onCompleted event of the Page (i.e. when the app starts).
• The logic of the business day (i.e. Mon-Fri) plus/minus and time difference calculations cannot be done directly by the native JavaScript date/time functions. This needs to be handled by the developer separately.

(English, demo with N950)

(Cantonese, demo with N9)

Source Maemo.Org

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Gambling

### DraftKings and Flutter stock plummets following proposed Illinois tax hike

Both DraftKings and Flutter Entertainment saw their stocks fall yesterday (May 28) when a gambling tax hike was proposed in Illinois. Illinois lawmakers discussed the increase over the weekend in...

• Gaming
##### XDefiant Twitch Drops: All weekly rewards explained
Jacob Woodward18 mins
• SEO
##### Here's what a huge Google leak tells us about search rankings
Sam Shedden22 mins
• Gaming
##### Five-star Apple Arcade games Fantasian coming to other platforms according to leak
Paul McNally23 mins

#### Get the biggest tech headlines of the day delivered to your inbox

By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

Tech News

Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

In-Depth Tech Stories

Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

Expert Reviews

Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.