Stencyl 3.4.0 is now out. Get it now!

Date Extension

Vectrex71

  • Posts: 520

« Last Edit: October 15, 2012, 09:26:25 am by Vectrex71 »

Dom818

  • *
  • Posts: 1296
That would display the date in all numerical form, but yes, that would work. I will show you what I would do when I get home.

Dom818

  • *
  • Posts: 1296
I attached some code to show the current time.

You can use the same basic format to show the date.

For showing the name of the month or week of the week, make a list with all of the names and use the get item from list block with the get current "month/ day of week" to grab the corresponding item.


Leaufai

  • Posts: 327
Could you perhaps change text on the blocks to lower case? All stock Stencyl blocks are written in lower case. Looks so out of place when Capitalized and All lower case is mixed.

Dom818

  • *
  • Posts: 1296
Could you perhaps change text on the blocks to lower case? All stock Stencyl blocks are written in lower case. Looks so out of place when Capitalized and All lower case is mixed.

Done, you can download the new version from the first post.

Leaufai

  • Posts: 327
That was quick. Thanks.

Dom818

  • *
  • Posts: 1296
Here is the next version of the Date extension. I decided to add a function to get the days in a certain month during any given year (not sure how many years it tracks). I hope this works as expected and if it doesn't, let me know (I don't usually code anything by hand so something may be off). The new file is available on the first post.

« Last Edit: March 16, 2013, 09:36:55 am by Dom818 »

Dom818

  • *
  • Posts: 1296
I found a bug in the current version of my extension which has been fixed now. The new days in a month block was always a month off, this has now been fixed.

LePoulpe

  • Posts: 181
I would appreciate some clarifications about your extension.

When "I get the current hour", it always returns the time in 24-hour format (on iOs) even if I change the time zone or the hour format.

Do you have the same kinds of results ?

Thanks

Dom818

  • *
  • Posts: 1296
I believe that is how iOS returns the hour format. If you need it to be 12 hour, you can make an if statement which sees if the hour is more than or equal to 13. If it is , subtract 12 from the hour.

LePoulpe

  • Posts: 181
Thanks for the clarification and thank you very much for this useful extension.

GwefTech

  • Posts: 295
Anyone know how I could calculate how many days between two dates, using this extension?

I know I can set today's date by using the extension,  but can i make a date attribute somehow, and then do the calculation?

I now the calculation should be this:

today = [get current Year + get current month + get current day]
expiryDate = [2013-12-1]
difference = today - expirydate
daysleft = floor(difference/(60*60*24))

but it won't work as today and expiry dates are strings.  the attributes need to be dates.   

FortySe7en

  • Posts: 304
You could treat the strings 'as number' perhaps?
By the way, thanks a lot for this extension!

« Last Edit: November 11, 2013, 12:55:58 pm by FortySe7en »

Dom818

  • *
  • Posts: 1296
You could treat the strings 'as number' perhaps?
By the way, thanks a lot for this extension!

I'll look into it soon.