Timepiece | Intuitive date handling in Swift | Date Time Utils library
kandi X-RAY | Timepiece Summary
kandi X-RAY | Timepiece Summary
Intuitive date handling in Swift.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Timepiece
Timepiece Key Features
Timepiece Examples and Code Snippets
Community Discussions
Trending Discussions on Timepiece
QUESTION
I'm trying to localize times that are in UTC when the only thing I know about the destination time is the longitude and latitude. I've come up with something that works, but feels kludgy:
...ANSWER
Answered 2021-Apr-29 at 21:36Your question boils down to the following:
How do I create a DateTime object from a timestamp using the
%Y-%m-%dT%H:%M:%S
format. I have the appropriate time zone as a DateTime::TimeZone object.
To parse a date-time into a DateTime, one should first look for an appropriate DateTime::Format:: module.
DateTime::Format::Strptime would be the most similar to your current attempt.
QUESTION
The component I'm working on is a time input for a form. The form is relatively complex and is generated dynamically, with different fields appearing based on data nested inside other data. I'm managing the state of the form with useReducer, which has worked very well so far. Now that I'm trying to implement a time input component, I'd like to have some basic validation, in particular so I don't get junk non-formatted data into my database. My way of thinking about it was that my database wants one thing: a time, formatted per ISO8601. The UI on the other hand could get that date any number of ways, in my case via an "hour" field, a "minute" field, and eventually an am/pm field. Since multiple fields are being individually validated, and then combined into a single ISO string, my approach was to have useState manage the individual fields and their validation, and then dispatch a single processed ISO string to my centralized state.
To get that to work I tried having the onChange listener of the input fields simply update the local state with a validated input, and then have useEffect "listen" to the local state using its dependency array. So each time local state changes, the useEffect callback dispatches an action with the new input, now processed into an ISO string, in its payload. I was a bit surprised this worked, but I still have a lot to learn about.. all of it. Anyways this worked great, or so I thought..
Since the component in question, TimePiece, is being rendered dynamically (inside nested loops) inside of its parent's parent component, when the user changes the form a bit, the TimePiece component gets rendered with new props and state. But therein lies the rub, every time TimePiece is rendered, it has the same state as every other "instance" of TimePiece (it's a function component though). I used some console.logs to find out it's actually maintaining it's separate state until the moment in renders, when it's then set to the state of the last "instance" that was modified.
My central useReducer state is keyed by a series of ids, so it's able to persist as the user changes the view without a similar problem. It's only the local state which isn't behaving properly, and somewhere on the re-render it sends that state to the central useReducer state and overwrites the existing, correct value...
Something is definitely off, but I keep trying different version and just breaking the thing. At one point it was actually fluttering endlessly between the two states... I thought I would consult the internet. Am I doing this completely wrong? Is it some slight tweak? Should I not have dispatch inside of useEffect with a local state dependency?
In particular, is it strange to combine useState and useReducer, either broadly or in the specific way I've done it?
Here is the code.. if it makes no sense at all, I could make a mock version, but so often the problem lies in the specifics so I thought I'd see if anyone has any ideas. Thanks a bunch.
The functions validateHours and validateMinutes shouldn't have much effect on the operation if you want to ignore those (or so I think.....).
"Mark" is the name of the field state as it lives in memory, e.g. the ISO string. io is what I'm calling the user input.
...ANSWER
Answered 2021-Feb-18 at 06:39Ok, after spending a few hours just trying to trace the data flow from TimePiece
back through all the abstraction to "state", and back, and all I can really say is that you've a ton of prop drilling. Almost all your components consume the same, or very similar, props
What I finally found is that TimePiece
doesn't unmount when switching between what I guess you are calling Phorms(??), which you've abstracted via a Widget
. Once I found what wasn't unmounting/remounting as I'd expect to display the different hours & minutes state the solution was simple: Add a React key corresponding to the Phorm when you switch between pull-ups and push-ups.
Phorm.js
QUESTION
I am looking to calculate the highest precision lat lon for the subsolar point, in a particular datetime moment, as is reasonably possible using pyephem, with the help of some other library(s) if they are needed.
Relevant context: Anyone who has used pyephem, already knows that for certain calculations it requires certain setup values before computing body positions, those values including the datetime (epoch of the observation), the location of the observer, and of course, the body being investigated. Solutions for the subsolar point through the use of pyephem, that I have found online, show the time in utc as the time needed for the pyephem setup.
Remembering way back to my first exposure to astronomy, and to celestial navigation, utc is a variant of a mean day, compared to an actual solar day, where an actual solar day's duration throughout the year varies due to several factors of the nature of the earth's orbit. Because the length of an actual solar day varies throughout the year, for certain types of astronomical calculations, this requires the Equation of Time to more precisely map the actual solar day measurements to a mean and fixed 24 hour day system such as utc. Before the advent of sufficiently accurate 'pendulum movement' clock mechanisms, and now crystal controlled clock mechanisms, going back to when sundials were the accurate timepiece, the more sophisticated sundials included markings to apply a yearly approximation of this important Equation of Time, soon after it had been observed and definitively documented. Therefore, relevant to my question, since utc is a variant of mean day, and not the true solar day, but normalized to 24 hours exactly, there is this question now of how or if pyephem incorporates the Equation of Time in its right ascension solutions for the sun. At present, I imagine the EoT is required for accuracy, as I try to visualize the sun's position against the background of stars, as seen from the earth, as the earth revolves around the sun, with historically observed variations that are made available and useful and essential with the Equation of Time.
Summary then of my question:
If it is not necessary to explicitly enter an EoT value in pyephem, because it is not relevant for computing the most accurate subsolar point, please explain why. If it is relevant, as I presently think it is, please tell me if pyephem, in its right acension calculation of the sun (and other bodies), as a body, does in fact, apply the Equation of Time as appropriate. Does it do so transparently? Is there a way to input an explicit value for it, if such is known, an EoT value that might be more accurate or more up to date compared to what pyephem is using transparently?
Some initial research results that formed the question: Upon doing a search through various search engines, I found several posts in topical forums that give what seems a very simple answer for finding the subsolar point. Finding the lattitude apears to be the less complicated part of the solution, being simply the computed declination. Finding the longitude is where the question arose in my thinking, and now I wonder if it is applicable for the declination as well, since using the properly precise time is essential for the most precise result of both declination(lat) and longitude of the subsolar point. I always applied the EoT from the Nautical Almanac, back when I was involved with celestial navigation.
Two links, specific to pyephem, present the same approach to the subsolar point solution. When the question(s) was first asked, Brandon Rhodes quickly presented the single line formula using pyephem's computing of the sun's right ascension. His was specifically the code for the longitude calculation in a more theoretical tone, without all the pyephem contextual details. Liam Kennedy presented a more complete context of python code, showing those additional pyephem details, so that one could 'copy and paste' the entire block of code, (needing only to add the import ephem and import datetime), and modify it as appropriate, which I also found to be a useful review. The code is from these links...
Confusion with using dec/ra to compute sub-lunar location
subsolar point:
Brandon's code
...ANSWER
Answered 2019-Dec-23 at 14:43I think that your question, stated more briefly, is: does the libastro
library that underlies PyEphem assume that the Earth’s orbit is a circle along which the Earth travels at a uniform rate? Because if it assumes a circular orbit and uniform rate for the Earth, then a correction — the Equation of Time — would need to appear for the fact that the Earth in fact varies its speed along its orbit.
I suggest that you can answer this question for yourself experimentally. If PyEphem assumes uniform circular motion for the Earth, then the number of degrees traveled by the Sun each day will be the same. Try looping over a long series of days. For the same time each day, ask the Sun for its right ascension and declination, and then use separation()
to check the angle traveled between those points.
If the angle traveled by the Sun is the same each day, then PyEphem is modeling the Sun’s motion very poorly and you will need to apply an Equation of Time correction to get its true position.
But if the daily angle is varying — small in July, large in January — then PyEphem must be modeling the Earth’s motion more accurately. If you dig into the source code, you will find that its model is called the VSOP87 model of predicting where the Earth and Sun are. Your own experiments should show how the model behaves as the Sun travels the sky through the year.
QUESTION
When I point the Tomcat and TomEE Integration
plugin in IntelliJ Ultimate 2017.2 via menu item Run
> Edit Configurations
to a fresh download of Tomcat 8.5.16, my Vaadin 8.1 app runs successfully. Good.
But when I optionally point the configuration’s Server
> Application Server
> Configure
button > Tomcat base directory
to an empty folder, I get a message:
Cant find directory 'Users/basilbourque/apache-tomcat-base-dev/conf'
➠ Must I create this conf
folder?
In contrast to IntelliJ, when I point NetBeans IDE to an empty folder when running Tomcat externally, it automatically populates the empty folder with the entire hierarchy of folders and files needed to run the app.
So, okay, I create a conf
folder in my otherwise empty folder. This satisfies the Edit Configurations
panel. Next, I run my app by running this configuration.
Notice how Unnamed_
is prepended to my application name (timepiece
), I get this message in a floating dark-red box within the IntelliJ IDE window:
Error running 'Tomcat 8.5.16'
Cannot load /Users/basilbourque/Library/Caches/IntelliJIdea2017.2/Unnamed_timepiece/conf/server.xml: /Users/basilbourque/Library/Caches/IntelliJIdea2017.2/tomcat/Unnamed_timepiece/conf/server.xml (No such file or directory) (5 minutes ago)
➠ Must I create a server.xml?
Such a requirement confuses me given that as I said above, NetBeans simply populates the external Tomcat "base" empty folder as needed entirely and automatically.
I am also curious why the message repeats the same path with a colon in the middle, though that is a minor issue.
...ANSWER
Answered 2018-Jan-07 at 04:38This directory is used to have the configuration that is different from the default Tomcat conf
in the root of the server installation.
- Copy
TOMCAT_HOME/conf
intoCATALINA_BASE/conf
. - Select this new
CATALINA_BASE
in the IntelliJ Run > Edit Configurations dialog.
This way you can have the same physical installation of the server, but run multiple server instances with different configurations. IntelliJ IDEA expects the pre-configured CATALINA_BASE
from you, it will not populate it automatically.
QUESTION
The Vaadin Framework guide has a page describing how to use Column Renderers in a Vaadin Grid. And this page describes implementing renderers, but all too briefly.
I want to implement a InstantRenderer
to complement the partial set of java.time renderers added in Vaadin 8.1. Renderers were added for LocalDate
& LocalDateTime
but not for Instant
, OffsetDateTime
, and ZonedDateTime
. For my Instant
renderer I am currently simply applying the current default time zone (ZoneId
) to get a ZonedDateTime
on which I call the toString
method. More could be done, but this is just to get started.
So my code should be very similar to the provided LocalDateTimeRenderer
. I am trying to follow that code as an guide.
In searching the Vaadin source code and reading the doc, it seems I need three pieces of source code:
InstantRenderer
( similar toLocalDateTimeRenderer
)InstantRendererConnector
( similar toLocalDateTimeRendererConnector
)InstantRendererState
( similar toLocalDateTimeRendererState
)
I have done this, and it all compiles. But my table fails to render, all I get is a white empty box on the page. No errors appear on the console or logs. If I remove my use of my InstantRenderer
, and fall back to letting my Instant
objects be rendered by the default of their own toString
methods, all is well and the table appears as expected. So I know my custom renderer is at fault.
I am a newbie when it comes to "server-side" vs "client-side" Vaadin.
➠ Is there some kind of packaging I need to perform? Currently I have my three classes in my Vaadin project alongside the MyUI
source file.
➠ Am I missing some other piece?
I instantiate my renderer by calling the no-arg constructor:
...ANSWER
Answered 2017-Sep-05 at 20:14Yes, special packaging is required. You cannot simply toss the Vaadin Grid column renderer implementation classes into a regular Vaadin app.
Two of the three classes needed for a column renderer implementation involve client-side development, rather than the usual server-side development we do commonly in Vaadin app work.
Fortunately, this is easier than it might sound. To just do a simple column renderer, Vaadin fortunately provides some super-classes that do most of the heavy-lifting. So we need not learn about all the gory details of the GWT and JavaScript magic that goes on under the covers in Vaadin.
The path to success involves:
- Creating a separate project using a Vaadin-provided template to build your own Vaadin Add-On.
- Populating that project with source code taken from the Vaadin Framework GitHub project.
vaadin-archetype-widget
Start a new project using a multi-module Maven archetype provided by the Vaadin team: vaadin-archetype-widget
seen in this list.
addon
module
Once you have created a project from that archetype in your IDE, add your three column renderer classes as shown in this screen shot for an Instant
renderer.
Renderer
class goes in the 'addon' module’s main package.RendererConnector
&RendererState
class files go in the 'addon' module’s nestedclient
package.
Of course, in real work you would delete the example MyComponent…
files created by the archetype.
demo
module
Once built you can try your column renderer in the 'demo' module’s Vaadin app by importing the package of the 'addon' module. In this case:
QUESTION
When running my Vaadin app on Tomcat 8.5 externally from IntelliJ Ultimate 2017.2 on macOS Sierra, I get an error message:
Artifact timepiece-ui:war exploded: Error during artifact deployment. See server log for details.
➠ Where is this ‘server log’?
When I look in apache-tomcat-8.5.20
> logs
, the folder is empty. Indeed, I cannot find any trace of my app being deployed within apache-tomcat-8.5.20
.
➠ Is there some other place where IntelliJ+Tomcat is placing my app and the server logs?
...ANSWER
Answered 2017-Aug-14 at 03:23IntelliJ IDEA shows the log files you configure in the Run/Debug configuration settings as the separate tabs in the Run or Debug tool window.
For Tomcat the actual logs are placed under CATALINA_BASE/logs
directory. The value of the CATALINA_BASE
set by IntelliJ IDEA will be printed in the console of the Run or Debug tool window.
You can also find the log files under idea.system.path/tomcat//logs/
.
QUESTION
I am trying to allow multiple modals in a single page. The html set-up is:
...ANSWER
Answered 2017-Aug-12 at 23:49Javascript functions take their context with them, even when they are executed later on. Within your for
loop you define two functions (one to open the modal and one to close). Each of those functions is accessing the loop variable i
as it is defined outside the function. If i
is modified (as it is during the loop), the function accesses the new, modified value when it executes.
(this is both a big difficulty and a big opportunity in javascript!)
You can achieve what you want in this case simply by defining a new variable with in your for loop:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Timepiece
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page