It is currently Sat Oct 31, 2020 8:30 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [Module] Calendar - Module (all OS)
PostPosted: Sun Dec 01, 2019 4:05 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1265
Location: Germany
Calendar Gadget - Module (all OS / DPI / 64Bit)

Calendar is the light version of CalendarEx and is only intended for selecting a date.

  • support of Date64
  • automatic size adjustment
  • support of GUI themes (needs ModuleEx.pbi)

Image

Code:
; Calendar::DefaultCountry()     - set default language for all gadgets
; Calendar::Disable()            - similar to 'DisableGadget()'
; Calendar::DisableReDraw()      - disable/enable redrawing of the gadget
; Calendar::Gadget()             - similar to 'CalendarGadget()'
; Calendar::GetAttribute()       - similar to 'GetGadgetAttribute()'
; Calendar::GetData()            - similar to 'GetGadgetData()'
; Calendar::GetDate()            - similar to 'Date()', but 64Bit
; Calendar::GetDay()             - returns selected day
; Calendar::GetID()              - similar to 'GetGadgetData()', but string instead of quad
; Calendar::GetMonth()           - returns selected month
; Calendar::GetState()           - similar to 'GetGadgetState()'
; Calendar::GetText()            - similar to 'GetGadgetText()'
; Calendar::GetYear()            - returns selected year
; Calendar::Hide()               - similar to 'HideGadget()'
; Calendar::MonthName()          - returns name of month in the current language
; Calendar::SetAutoResizeFlags() - [#MoveX|#MoveY|#Width|#Height]
; Calendar::SetColor()           - similar to 'SetGadgetColor()'
; Calendar::SetData()            - similar to 'SetGadgetData()'
; Calendar::SetDate()            - set date
; Calendar::SetFont()            - similar to 'SetGadgetFont()'
; Calendar::SetID()              - similar to 'SetGadgetData()', but string instead of quad
; Calendar::SetState()           - similar to 'SetGadgetState()'
; Calendar::WeekDayName()        - returns name of weekday in the current language

Download: CalendarModule.pbi

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Fri Jul 10, 2020 8:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 395
Location: Germany
Great modules, thanks :)

A little warning though - it all relies on the date64 functions and at the bottom of them, they have a system call which works great in win10, but in win7, the date times are limited from 1970 upwards.
If the calendargadget shows a year below 1970, some calls will return 1.1.1970 as that is the lowest time the used windows API call knows (1.1.1970 is 0 in windows 7, it is the unix/posix epoch time beginning).

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Sat Jul 11, 2020 12:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 427
Location: Germany
Bitblazer wrote:
A little warning though - it all relies on the date64 functions and at the bottom of them, they have a system call which works great in win10, but in win7, the date times are limited from 1970 upwards.
If the calendargadget shows a year below 1970, some calls will return 1.1.1970 as that is the lowest time the used windows API call knows (1.1.1970 is 0 in windows 7, it is the unix/posix epoch time beginning).
I have just tested it on Windows 7 x64 and can't find any 1970 limit. Do you have a sample code that demonstrates the problem? Note that this module draws its own calendar gadget and does not use the calendar gadget from PureBasic.

The Date64 module supports the following date range under Windows:
  • Minimum: 01.01.1601 00:00:00
  • Maximum: 31.12.9999 23:59:59

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Sat Jul 11, 2020 12:35 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 395
Location: Germany
I guess it depends which system function you trigger with a date64 call. I requested the state of a calendar gadget with a date in 1966 and calculated the year to display it. During that process, a windows system function was called. So i used CalendarEx::GetState() and then the CalendarEX::Year() function triggered a system call and that returned 1.1.1970 due to a request outside the supported range. It is actually documented here and this limitation seems to come from some of the supported operating systems (1.1.1970 is the Posix epoch time).
It showed up in my windows 7 english ultimate 64-Bit MSDN version and is gone in windows 10. So i guess it is useful for operating system fingerprinting ;)

It might depend on the actual win7 version (oem, retail, S, home, professional, ultimate etc.)

I discussed it a bit on the purebasic discord server where i also pasted some MSDN/wikipedia references.

IT/CS can be a real mess. No matter if you explore DPI, Date, Font, Image or archive formats. The deeper you dig, the uglier it gets. For fun: https://en.wikipedia.org/wiki/Unix_time

ps: 2038 will be a glorious year for software developers and newspapers, probably not for the computer users ;)
pps: more date fun and many widely used programming languages actually have the same limitation

_________________
webpage


Last edited by Bitblazer on Sat Jul 11, 2020 3:10 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Sat Jul 11, 2020 1:10 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 395
Location: Germany
Sicro wrote:
The Date64 module supports the following date range under Windows:
  • Minimum: 01.01.1601 00:00:00
  • Maximum: 31.12.9999 23:59:59


Thats actually why i posted this little warning. This problem lurks in the background and is only triggered by some conversion functions of the operating system. I could compile a test binary and then debug it to pinpoint the windows 7 system call, but it seems to depend on my specific windows 7 version. I am glad i noticed it on my system before it happened on a customer machine.

The windows it happened on, was windows7 ultimate english 64bit with all patches up to date.

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Sun Jul 12, 2020 11:56 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 427
Location: Germany
Bitblazer wrote:
So i used CalendarEx::GetState() and then the CalendarEX::Year() function triggered a system call and that returned 1.1.1970 due to a request outside the supported range.
Code:
; CalendarEx::GetState()           - returns selected date

[...]

Declare.i GetState(GNum.i)
At first I suspected that the problem arises with you because of the above mistake. GetState() must return a quad value to support the full date range of Date64. But for you the error can't be the culprit if I read this:
Bitblazer wrote:
It showed up in my windows 7 english ultimate 64-Bit
Did you maybe compile the program as 32-bit?

Bitblazer wrote:
1.1.1970 is the Posix epoch time
Yes, but dates before that are still possible by returning a negative seconds value.

Bitblazer wrote:
ps: 2038 will be a glorious year for software developers and newspapers, probably not for the computer users ;)
Many systems have switched to 64-bit Unix timestamps. Windows does not use Unix timestamps and is therefore not affected by the problem.

Quote:
Windows
1 January 1601 to 14 September 30,828
https://en.wikipedia.org/wiki/System_time#Operating_systems

Bitblazer wrote:
This problem lurks in the background and is only triggered by some conversion functions of the operating system. I could compile a test binary and then debug it to pinpoint the windows 7 system call, but it seems to depend on my specific windows 7 version.
These are the best bugs (which can't be tested properly). :(

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Calendar - Module (all OS)
PostPosted: Mon Jul 13, 2020 9:18 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 395
Location: Germany
Just for fun, i digged a bit deeper into this problem. The problem is not a date function limitation of my win7 version, but this call's parameter

http://bitblazer.de/files/date64problem.jpg

It is 0 with my win7 installation. The Gadget number (GNum) is correct and the map element is found, but this line results in a parameter of 0 for the Day_() call. And 0 is correctly decoded as 1.1.1970 :)

So the problem is the Calendar()\Current\Focus reference.

ps: sorry, but the forum software didnt let me include the image because "It is not possible to determine the dimensions of the image.". So i can just provide this link. (forum update/fix time?)

_________________
webpage


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye