We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

Shorten the weekday name/date on Lockscreen clock [answered]

asked 2016-07-30 15:50:58 +0300

Spam Hunter gravatar image

As the title suggests, how do I shorten the Weekday name on the Lockscreen?, I don't understand the mechanism for time/day/date construction using QML in Sailfish.

For example, I want to reduce each Weekday name down to 3 letters only; `Sun, Mon; Tue; Wed; Thu; Fri, Sat' and eventually, reduce the date to one line.

The text in the relevant Clock.qml file gives this line of text;

    text: {
        var day = Format.formatDate(time, Format.WeekdayNameStandalone)
        return day[0].toUpperCase() + day.substring(1)

The above code simply returns; Saturday - but I'd like to see Sat 30 Jul

For the month, the text also in Clock.qml gives this line;

    text: Format.formatDate(time, Format.DateMediumWithoutYear)

The above simply displays; 30 Jul which is what I'm after, as previously described.

Any info appreciated

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by Spam Hunter
close date 2016-07-30 18:07:00.004304

Comments

2

isnt there a subString(startpos,length) ?

i would try day =day.substring(0,3)

pawel ( 2016-07-30 17:22:48 +0300 )edit
1

Thanks @pawel, you may well be right, but meanwhile, I have worked out another way and have achieved what I was after; the date in short form, i.e. Sat 30 Jul.

Spam Hunter ( 2016-07-30 18:01:40 +0300 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2016-07-30 18:04:26 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2016-09-17 13:48:57 +0300

Spam Hunter gravatar image

I have answered my own question, but I'll leave the result here as others may find it useful.

    text: { updatesEnabled: timeText.time
        Qt.formatDateTime(new Date(), "ddd dd MMM")

The above now returns; Sat 30 Jul

image description

edit flag offensive delete publish link more

Comments

Above EDITED; to reflect how the DATE mechanism updates. My initial solution did not include updatesEnabled: timeText.time - as a direct result, the DATE was not updating on the stroke of MIDNIGHT.

Spam Hunter ( 2016-08-01 12:46:44 +0300 )edit

There's a downside with this and it's that if you have a time locale that differs from your language the date will be shown in the time locale language, e.g. I have english as language but have changed my LC_TIME to Swedish (to get Monday as first day of week) and I would see Lör 30 jul instead of Sat 30 Jul with the above suggestion. I'd use the original suggestion (modified) with substring (I haven't verified if it works as intended):

text: {
    var day = Format.formatDate(time, Format.WeekdayNameStandalone)
    return day[0].toUpperCase() + day.substring(1,2) + ' ' + Format.formatDate(time, Format.DateMediumWithoutYear)
}

It also need the updatesEnabledsomewhere as well

Mohjive ( 2018-09-13 04:24:00 +0300 )edit

Question tools

Follow
1 follower

Stats

Asked: 2016-07-30 15:50:58 +0300

Seen: 356 times

Last updated: Sep 17 '16