[Plugin] System date and time

Post your completed addons to share with the community

Post » Sun Nov 02, 2014 12:21 am

@Naji
Image
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Thu Nov 13, 2014 10:13 am

Hi Im working on a Christmas Calendar

Can I setup an event/action to only be active on a date for december
using this plugin ?

Cheers
Flemming
B
22
S
12
G
10
Posts: 322
Reputation: 7,353

Post » Thu Nov 13, 2014 10:16 am

@flemmig

I guess you need to check the date to see if now is at a specific day.

+ every tick
+ Date.Month = 12
+ Date.Date = 25
- do someting...
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Thu Dec 04, 2014 11:26 pm

This plugin is really useful for me. Thank you very much.

I have a (probably noob) question: Is it possible to print the year only with the las two digits? i.e.: just '14' instead of '2014'.

Thanks again,

Fer
B
7
S
1
G
3
Posts: 11
Reputation: 1,229

Post » Fri Dec 05, 2014 7:17 am

@FERdeBOER

str(Date.Year % 100)
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Fri Dec 05, 2014 12:48 pm

rexrainbow wrote:@FERdeBOER

str(Date.Year % 100)


That's definitively better than what I was thinking about, passing it to a variable and substracting 2000 :lol:

Thank you very much!
B
7
S
1
G
3
Posts: 11
Reputation: 1,229

Post » Mon Jan 19, 2015 12:27 pm

To author:

i had analyzed your code and i found the problems

Code: Select all
Exps.prototype.Year = function (ret, timestamp)
   {
       var today = (timestamp != null)? new Date(timestamp): new Date();
      ret.set_int(today.getFullYear());
   };

.....

Exps.prototype.UnixTimestamp = function (ret)
   {
       var today = new Date();
        ret.set_float(today.getTime());
   };


reference:http://www.w3schools.com/js/js_dates.asp
JavaScript dates are calculated in milliseconds from 01 January, 1970 00:00:00 Universal Time (UTC).
One day contains 86,400,000 millisecond.

seems in javascript
a Date object include milliseconds (1 second = 1000 milliseconds) and the standard unix timestamp is 1421664587 (2015/1/19 18:49:47 GMT+8) is NOT include milliseconds part
so the unix timestamp should multiply by 1000 to 1421664587000
[unix timestamp] * 1000 = [java Date]
1421664587 * 1000 = 1421664587000


to get a unix timestamp from Date object just need to Date.getTime() divide by 1000
[java Date] / 1000 = [unix timestamp]
1421664587000 / 1000 = 1421664587


Code: Select all
Exps.prototype.Year = function (ret, timestamp)
   {
       var today = (timestamp != null)? new Date(timestamp*1000): new Date();
      ret.set_int(today.getFullYear());
   };

...
Exps.prototype.UnixTimestamp = function (ret)
   {
       var today = new Date();
        ret.set_float(today.getTime()/1000);
   };


and i modified the plugin to above code
i got a correct result to convert from unix timestamp to Year
This is what i suggest in your next update
i wish this may help you to solve this problems
You do not have the required permissions to view the files attached to this post.
B
17
S
7
Posts: 360
Reputation: 2,202

Post » Mon Jan 19, 2015 4:55 pm

@fongka2

Yes, the return value is based on milliseconds, which described in ACE table.
Code: Select all
Expression:UnixTimestamp Get current number of milliseconds since the epoch.

Since users had used it based on milliseconds, the changing will break their projects.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Wed Jan 21, 2015 6:14 pm

Thank you Rex. Great plugin. This is exactly what I needed.
B
28
S
5
G
2
Posts: 97
Reputation: 2,052

Post » Fri Jan 23, 2015 3:10 am

Thanks, Rexrainbow!
Image Image
B
35
S
16
G
7
Posts: 144
Reputation: 6,255

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests