Last modified: 2014-08-06 15:49:11 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T70872, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 68872 - Provide some easy way to get time components in the wiki's local time (not UTC or server-local time)
Provide some easy way to get time components in the wiki's local time (not UT...
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-30 19:21 UTC by Sorawee Porncharoenwase
Modified: 2014-08-06 15:49 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sorawee Porncharoenwase 2014-07-30 19:21:59 UTC
I found that frequently I need to get time table (a table with fields "year", "month", ...) of a timestamp in the wiki's local time. It is not possible to obtain this table via os.date() because the function can't accept timestamp as a parameter, and the function also can't deal with the wiki's local time. The workaround is to do something like:

timetable = {
    year = tonumber(lang:formatDate(...)),
    month = tonumber(lang:formatDate(...)),
    day = tonumber(lang:formatDate(...)),
    hour = tonumber(lang:formatDate(...)),
    ...
}

which is redundant and ridiculous. I therefore propose that timetable can be obtained via lang:formatDate('*t', timestamp, local).
Comment 1 Brad Jorsch 2014-08-06 15:21:32 UTC
There should be some way to get time components in the wiki's local timezone, yes. But I don't think that '*t' to formatDate is the best way to do it.

The ideal would be to fix os.date to use the wiki local time instead of the server local time when in local-time mode, IMO. But if that's prohibitively difficult, either something that fits in better with the formatDate interface or a separate function to get the array (IMO the latter is more likely).
Comment 2 Sorawee Porncharoenwase 2014-08-06 15:49:11 UTC
With os.date(), the second parameter must be value from os.time() or nil; it can't accept '-7 days' or '@1407339935' like lang:formatDate().

However, I don't oppose if you think that changing os.date() is more proper.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links