How do I convert seconds to HH.MM:SS via MediaWiki (plus Semantic Media Wiki)?
I tried and tried and just can't find a way.
The duration in seconds comes via filling out a template.
As I can't install more extensions to the Wiki the only ways are via SMW and parser functions.
Thank you very much in advance!
You should be able to do this with the time parser function:
{{#time: H.i.s | #123 }}
It't not strickly treating it as a time duration, but rather a time from the unix epoch, but if you don't go over 24 hours it doesn't really matter.
If you need to go higher, then you can build up a custom expression using the trunc operator, for example to get the number of hours:
{{#expr: trunc (123/60/60) }}
Related
I'm trying to get the current time in UTC in a UWP application. This should be a simple matter of constructing a DateTime object
DateTime const now{ clock::now() };
and accessing its UniversalTime field. However, that field does not appear to have been projected into C++/WinRT.
How do I get the current time in UTC using C++/WinRT?
Looks like a documentation bug. That field doesn't exist in C++/WinRT. Instead, DateTime is projected as a std::chrono::time_point. But similar to C++/CX, the documentation for the struct (not the field) is still somewhat accurat - it has the same granularity as FILETIME. But even easier than extracting the value youself, winrt::clock provides static methods to_file_time and to_time_t that convert DateTime to
FILETIME or time_t, respectively.
I'll get the documentation fixed up, and I've been meaning to write a blog post about how C++/WinRT seamlessly interops with std::chrono for timekeeping. I'm a a fan of std::chrono, and incorporating it into C++/WinRT was my idea, so the haters know who to blame. :)
I run a scheduling site that allows users to set a timezone for their account. They can then schedule 'posts' on a calendar for that timezone. In the back-end, I take the time and convert it into UTC time (where a worker processes and picks up those posts on UTC time).
I run the site on Ruby (with Puma/Sinatra), but without Rails, and I'd like to stay away from Rails. There's HTML/ERB/JS in the front and a MYSQL backend.
I thought that simply adding/subtracting UTC offsets will solve all problems. I have a simple list that has TIMEZONE <--> UTCOFFSET and this worked very well — or so I thought.
And then I realised this does not work when a given timezone (or place) is in DST currently.
Vienna in the summer: UTC offset: +2h
Vienna in the winter: UTC offset: +1h
Is there a simple way to give Ruby (not Rails) a "timezone ID" and receive the correct adjusted UTC offset back?
Like:
user.timezone = "Europe/Vienna"
utc_adjusted_time = post.local_time.to_i + get_utc_offset(user.timezone)
Where get_utc_offset knows whether it is in DST or not. Any ideas?
I've gone through the IANA database (which is absolute overkill), I've searched through numerous Gists on Github, I've tried to abuse whatever Rails seemed to have, but didn't get very far.
How do you guys handle this? Ideally, as said, each post will be converted and saved to a DST-stripped UTC time. Thanks!
Just use the Ruby TZInfo gem.
Your use case is exactly the one shown in the readme:
require 'tzinfo'
tz = TZInfo::Timezone.get('America/New_York')
local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0))
utc = tz.local_to_utc(local)
period = tz.period_for_utc(Time.utc(2005,8,29,15,35,0))
id = period.zone_identifier
Looking at the docs for TZInfo::TimePeriod you can see the other information you asked about:
period.offset
period.dst?
... etc.
FYI - the Rails time zone support is based on this gem anyway. Then Rails goes and puts some funky aliasing over the top (which I advise against using). See the section on Rails in the timezone tag wiki.
I'm reading uptimes of several applications on different systems. Currently, when the application is launched, it creates an ID with a pingTime, and a pingTimeAsString. Both are read and shown in html like this (page automatically refreshes every few minutes):
<p>
System ID: {{ stat.sysID }}
Uptime: {{ stat.pingTimeAsString | date : 'mediumTime'}}
</p>
Is there a way to compare this pingTime or pingTimeAsString that is written in a file to the current time + a certain amount of minutes (the duration of how long since the last time the application responded to a ping/sent an update)? That way I can change the listing to display a ONLINE/OFFLINE sort of status?
Update: How the query looks from reading the RESTService:
[{"pingTime":"\/Date(1405706983530-0400)\/","pingTimeAsString":"Jul 21 2014 2:09PM","sysID":"2"}]
You could use the moment.js library to make the task easier:
moment().diff("\/Date(1405706983530-0400)\/") // different from now in milliseconds
or if you want the result in other units:
moment().diff("\/Date(1405706983530-0400)\/", "minutes");
you can even get a human friendly text like:
moment([2010, 7, 21]).fromNow(); // 4 years ago
Hope this helps.
good moring.
first of all. This is the most impressive community i ever saw!
Well several days i mused about the three-folded job of
a. getting
b. parsing
c. storing a number of pages.
Two days ago i thought that getting the pages would be the major-task. No this isnt the case - i guess that the parser-job would be a heroic task. Each of the pages that are intended to be parsed is a png-image.
So the question is - after getting all them. How to parse them!? This seems to be the issue. Guess that there are some perl-modules out there - that can help in doing this...
Well - i think that this job only can be done with some OCR embedded! Question: is there a perl-module that can be use here to support this task:
BTW: see the result-pages.
BTW;: and as i thought i can find all 790 resultpages within a certain range between
Id= 0 and Id= 100000 i thought, that i can go the way with a loop:
http://www.foundationfinder.ch/ShowDetails.php?Id=11233&InterfaceLanguage=&Type=Html
http://www.foundationfinder.ch/ShowDetails.php?Id=927&InterfaceLanguage=1&Type=Html
http://www.foundationfinder.ch/ShowDetails.php?Id=949&InterfaceLanguage=1&Type=Html
http://www.foundationfinder.ch/ShowDetails.php?Id=20011&InterfaceLanguage=1&Type=Html
http://www.foundationfinder.ch/ShowDetails.php?Id=10579&InterfaceLanguage=1&Type=Html
i thought i can go the Perl-Way but i am not very very sure:
I was trying to use LWP::UserAgent on the same URLs [see below]
with different query arguments, and i am wondering if LWP::UserAgent provides a
way for us to loop through the query arguments? I am not sure that LWP::UserAgent has a method for us to do that. Well - i sometimes heard that it is easier to use Mechanize. But is it really easier!?
But - to be frank; The first task " GETTING all the pages is not very difficult - if we compare this task with the parsing... How can this be done!?
Any ideas - suggestions -
look forward to hear from you...
zero
You do not need a Perl module, you only need the system function.
system qw[ tesseract.exe foo.png foo.txt ];
my $text = read_file('foo.txt');
You may need to preprocess the images to help Tesseract, say using ImageMagick like:
system qw[ convert.exe -resize 200% image.jpg foo.png ];
I want to know if there is a name for a function/method/library that converts a given date object with time information into something like:
a few seconds ago
2 minutes ago
about an hour ago
10 hours ago
yesterday
on 12-May-2010
and so on. I don't know what to google for, but I'm guessing that someone must have done this before. I'm specifically looking for an implementation in python (preferably a Django filter) that works on a datetime, but any open source implementation in any language will do really, for inspiration.
Google for "Fuzzy Date Time"
I believe it is called "fuzzy timestamp" (also "timedelta")
ruby and python examples are available in this SO question
git has its own date.c utility source for this kind of refspec date specification.
A ref followed by the suffix # with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) to specify the value of the ref at a prior point in time.
I don't really know the name of the method used, but you can find a Javascript implementation of what you're describing at DateJS.