Re: How to get uint64 from Gio.FileInfo
- From: Yaa101 <yaa101 xs4all nl>
- To: Mz <mengzhuo1203 gmail com>
- Cc: gnome-shell-list gnome org
- Subject: Re: How to get uint64 from Gio.FileInfo
- Date: Mon, 30 Jul 2012 01:53:32 +0200
Hi Mz,
Output from your uint64 is seconds.
I have been there, just use a javascript Date() object and feed it
seconds * 1000 as it ticks in milliseconds.
Here is a routine I used in a project recently to enlighten.
_dateString: function (seconds) {
let desktopSettings = new Gio.Settings({ schema:
'org.gnome.desktop.interface' }); let timeFormat =
desktopSettings.get_string(CLOCK_FORMAT_KEY);
let currentTime = new Date();
let modificationTime = new Date(seconds * 1000);
let dayString = "";
let i1day = 86400000;
let i2days = 2 * i1day;
let i7days = 7 * i1day;
let dateFormat;
if ((currentTime.getTime() - modificationTime.getTime()) >
i7days) {
// set abbriviated date string
dateFormat = _("%m-%e-%y");
}
else if (((currentTime.getTime()-modificationTime.getTime())>i2days)
&& ((currentTime.getTime() - modificationTime.getTime()) < i7days)) {
// set weekday string
dateFormat = _("%A");
}
else if (((currentTime.getTime() - modificationTime.getTime())> i1day)
&& ((currentTime.getTime()-modificationTime.getTime()) <i2days)) {
// set day string and time string
dayString = _("Yesterday at ");
dateFormat = (timeFormat == '24h') ? _("%R") : _("%I:%M
%p"); }
else if ((currentTime.getTime() - modificationTime.getTime()) <
i1day) {
// set day string and time string
dateFormat = (timeFormat == '24h') ? _("%R") : _("%I:%M
%p"); }
return (dayString +
modificationTime.toLocaleFormat(dateFormat)); },
--
(o_
//\ Regards, Groeten,
V_/_ Bas Burger.
On Sun, 29 Jul 2012 23:30:28 +0800
Mz <mengzhuo1203 gmail com> wrote:
> Hi, Guys and Girls
>
> Weird thing happened when I am trying to get File attribute from
> Gio.FileInfo
>
> a = Gio.file_new_for_path('/home/meng/test') //a new file I just
> created. b = a.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED,0,null)
> c = b.get_attribute_uint64(Gio.FILE_ATTRIBUTE_TIME_MODIFIED) //return
> 1343553596
>
> when I try to covert "1343553596" into a Date instance, I found that
> time-stamp is year 1970...
> I also tried to run Number.MAX_VALUE and it return XX.E+308 which is
> apparently more than UnixStamp's range.
>
> b.get_modification_time().tv_sec //return 1343553596 as previous.
>
> Now, I am totally surrender to this issue, can anyone enlighten me?
> _______________________________________________
> gnome-shell-list mailing list
> gnome-shell-list gnome org
> https://mail.gnome.org/mailman/listinfo/gnome-shell-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]