DateTools : Get some tools for dates

1.Introduction

Well…
Presenting my third extension to Community.
As you have read in title name of extension is DateTools and it is made specially to work with Dates.

2.Blocks

(i) Functions/Methods
scrnli_10_28_2019_9-08-31%20AM
scrnli_10_28_2019_9-09-23%20AM
scrnli_10_28_2019_9-09-59%20AM
(ii) Properties/Getter and Setter
07-18_41_07

3.Usage

It has not so much blocks but some examples can help you to understand its usage.
Here are instructions to use it:

blocks%20(28)

Returns day of given date.In above case it will return ‘Monday’
Note: You can also use DateTime besides Date

blocks%20(29)

Returns difference between two dates in milliseconds.
To convert it in seconds divide by 1000
To minutes divide it by 1000*60
To hours divide it by 1000*60*60
To days divide it by 1000*60*60*24

blocks%20(30)

Returns true if first date is after second date else false

blocks%20(31)

Returns true if first date is before second date else false

blocks%20(32)

Returns true if both dates are same else false

component_method%20(9)

Returns a list of available timezones

Converts epoch timestamp to date in the given date format in provided timezone

component_method%20(10)

Returns device’s current date and time

scrnli_10_28_2019_8-45-49%20AM

Returns current date and time in raw format

scrnli_10_28_2019_8-46-55%20AM

Returns current epoch timestamp

scrnli_10_28_2019_8-47-45%20AM

Display name of current timezone

scrnli_10_28_2019_8-48-33%20AM

Returns ID of current timezone

scrnli_10_28_2019_8-49-54%20AM

Converts millis in y d m s format

scrnli_10_28_2019_8-51-04%20AM

Converts epoch timestamp to date and time

scrnli_10_28_2019_8-53-47%20AM

Difference between two epoch timestamps in y d m s format

And for properties:

component_set_get%20(1)

Get format of date previously set
By default it will return dd/MM/yyyy

component_set_get%20(2)

Set format of date
Default format is dd/MM/yyyy

Note: Don’t forget to set format before using any function otherwise you can expect a runtime error

4.Aix/Extension file

Here are two download links:
Download Link 1: DateTools.aix (11.6 KB)

Download Link 2: DateTools.aix - Google Диск

5.Extras

Have a suggestion?
What are you waiting for?Just post that here.
Here you can post any suggestion,bug,question related to DateTools.

6.Updates/Bug Fixes

ChangeLog Version2

New Blocks

Some new blocks have been added in Version 2 to make it easier to work with dates…

component_method%20(9)

Returns a list of available timezones

Converts epoch timestamp to date in the given date format in provided timezone

component_method%20(10)

Returns device’s current date and time

scrnli_10_28_2019_8-45-49%20AM

Returns current date and time in raw format

scrnli_10_28_2019_8-46-55%20AM

Returns current epoch timestamp

scrnli_10_28_2019_8-47-45%20AM

Display name of current timezone

scrnli_10_28_2019_8-48-33%20AM

Returns ID of current timezone

scrnli_10_28_2019_8-49-54%20AM

Converts millis in y d m s format

scrnli_10_28_2019_8-51-04%20AM

Converts epoch timestamp to date and time

scrnli_10_28_2019_8-53-47%20AM

Difference between two epoch timestamps in y d m s format

Bug Fixes/Changes

  • Some minor changes
14 Likes

Nice work bro, really needs that extension, because i have made these things in my app with lot of blocks to compare dates and days etc , well done,

2 Likes

Glad you liked it:heart_eyes:
If you need any other feature then just post here…:sunglasses:

1 Like

Yes i liked it very much and i will check that when i go back to home and i think users also like same for time, like time compare Similar to this date tools there must be some thing like time tools ,

1 Like

I will try to make ‘TimeTools’…:slightly_smiling_face:

1 Like

Well Done Mate:blush:
But I Do Not Get Unique Ideas For Extension And Thats Why I Have Made One Basic extension :pensive:
But Well Done Many People Want This Feature in their app

1 Like

Actually I got inspiration to make DateTools from my most awaited project JobSwift , when I was working on a function related to date.

Got inspiration: 9:00am
Built extension: 10:00am

2 Likes

There is lot of ideas, just post in community what users need and you will get a list of ideas,

:heart_eyes:
Even Blocks Would Have Taken more time
nice work

:thinking:hmm lets try someday

1 Like

I have something for you.
Start using time tools extension.

2 Likes

ya i should try
but what will i do in it:cold_face:
which functions

Pm for more…
We are hijacking this topic.

1 Like

Good extension. Also all those methods can be done with simple blocks in procedures.
May be as one of the daily challenges we can see who can come up with the blocks equivalent of this extension.

5 Likes

Epoch in milliseconds to current timezone?

Better yet, here’s the code for it:

Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone();

/* debug: is it local time? */
Log.d("Time zone: ", tz.getDisplayName());

/* date formatter in local timezone */
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
sdf.setTimeZone(tz);

/* print your timestamp and double check it's the date you expect */
long timestamp = cursor.getLong(columnIndex);
String localTime = sdf.format(new Date(timestamp * 1000)); // I assume your timestamp is in seconds and you're converting to milliseconds?
Log.d("Time: ", localTime);

Just import the things you need. Credit to How to convert UTC timestamp to device local time in android - Stack Overflow

1 Like

ChalgeLog Version 2

New Blocks

Some new blocks have been added in Version 2 to make it easier to work with dates…

component_method%20(9)

Returns a list of available timezones

Converts epoch timestamp to date in the given date format in provided timezone

component_method%20(10)

Returns device’s current date and time

scrnli_10_28_2019_8-45-49%20AM

Returns current date and time in raw format

scrnli_10_28_2019_8-46-55%20AM

Returns current epoch timestamp

scrnli_10_28_2019_8-47-45%20AM

Display name of current timezone

scrnli_10_28_2019_8-48-33%20AM

Returns ID of current timezone

scrnli_10_28_2019_8-49-54%20AM

Converts millis in y d m s format

scrnli_10_28_2019_8-51-04%20AM

Converts epoch timestamp to date and time

scrnli_10_28_2019_8-53-47%20AM

Difference between two epoch timestamps in y d m s format

Bug Fixes/Changes

  • Some minor changes

Can You Update This Extension By Adding Event Blocks Like Time Tools Extension Made By @krishjha07? It Will Be Very Useful. Thanks.

Hi
Thank you for your precious suggestion.
But I am still not able to understand it.
Can you explain more?

1 Like


Can you create a block like this? So that we can store value in database?

That block is of TimeTools extension but why you want that block in DateTools extension :thinking:
Both are quite different